ffmpeg -help filter=transform
ffmpeg -help encoder=mjpeg
ffmpeg -help encoder=h264

截取一帧(从第一秒开始): ffmpeg -ss 1 -y -i merge8k.mp4 -f image2 -t 0.001 8k-3dv.jpg or ffmpeg -f h264 -i a.h264 -vf fps=1 -y a.jpg

crop尺寸:ffmpeg -y -i ${src}.jpg -filter:v “crop=in_w/4:in_h/3:in_w/4:0″ ${src}-2.jpg

Crop area with size 100×100 at position (12,34): crop=100:100:12:34

MP4 to MP3:  ffmpeg -y -i va.mp4 -q:a 0 -map a va.mp3

ffmpeg -stream_loop -1 -i input.mp4 -c copy -fflags +genpts output.mp4
to HLS: ffmpeg -i ${F1} -vcodec copy -acodec copy -f hls -hls_list_size 100 new/${HEAD}.m3u8

check channel number: ffprobe input.file -show_streams -select_streams a:0 | grep ‘channels=’

录制屏幕: ffmpeg -f v4l2 -r 10 -video_size 640×480 -i /dev/video0 /home/shock/t.mkv (not that v4l2 stands for video4linux2)

ffplay -f v4l2 -i /dev/video0
ffmpeg -f v4l2 -framerate 30 -video_size 840×620 -i /dev/video -c:v libx264 -r 30 -preset fast -tune zerolatency OUT

ffmpeg -f x11grab -framerate 30 -video_size 640×480 -i :0.0

WAV to M4A: ffmpeg -i SPTL007.WAV -c:a aac -strict -2 -b:a 256k -ac 4 t3.m4a

ffmpeg -f x11grab -framerate 30 -i :0.0 -c:v libx264 -r 30 -pix_fmt yuv420p -bf 0 -preset ultrafast -g 10 -b:v 3M -tune zerolatency -c:a libfdk_aac -f flv rtmp://r730.kandao.tech:1936/live/demo2
ffmpeg -i rtmp://localhost:1936/live/demo2 -c:v copy -b:v 1M -preset ultrafast -tune zerolatency -an -f flv rtmp://100015x.publish.z1.pili.qiniup.com/kandaovr/live?key=d2d0eff5-662b-47fd-b13f-bb56f54031b0

ffmpeg -i rtmp://pili-publish.live4.kandaovr.com/kandaovr4/demo?e=1471255883&token=QClzJjFYhx-NIT_vJRKf-tVzzTIPMGxhscDu890H:OmasOCdg0QPP4B_QGgYQeAxCcBU=

ffmpeg -f gdigrab -i desktop -c:v libx264 -r 30 -pix_fmt yuv420p -preset fast -tune zerolatency -c:a libfdk_aac -f flv rtmp://r730.kandao.tech:1936/live/demo2
ffmpeg -f gdigrab -framerate 30 -video_size 400×278 -i title=”Adobe Flash Player 9” -c:v libx264 -pix_fmt yuv420p -r 30 -bf 0 -g 10 -b:v 3M -preset fast -tune zerolatency -c:a libfdk_aac -f flv rtmp://r730.kandao.tech:1936/live/demo2

ffplay -tune zerolatency -i rtmp://r730.kandao.tech:1936/live/demo2
ffplay -i rtmp://100015x.live1-rtmp.z1.pili.qiniucdn.com/kandaovr/live

 

loop:

export src=a.mp4

export src=a.mp4

export dst=rmtp://xxx.xxx.xx

while :

do

ffmpeg -re -i ${src} -f flv ${dst}

done

 

ffprobe

统计总帧数

示例命令

$ ffprobe -v error -count_frames -select_streams v:0 \
  -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 \
  input.mkv

输出示例

  2600
  • 在此示例中, 2600 的输出是指读取帧数.
  • 由于整个文件必须解码,所以命令可能需要一段时间才能完成,具体取决于您的输入.

这个选项是什么意思

  • -v error 这将隐藏”info”输出(版本信息等),使解析更容易.
  • -count_frames 计算每个流的帧数,并在相应的流片段中进行报告.
  • -select_streams v:0 只选择视频流.
  • -show_entries stream = nb_read_frames 只显示读取帧数.
  • -of default = nokey = 1:noprint_wrappers = 1 将输出格式(也称为”writer”)设置为 default ,请勿打印每个字段( nokey = 1 ),并且不打印部分页眉和页脚( noprint_wrappers = 1 ).