ffmpeg -i input.mp4 -vcodec libx264 -profile:v baseline -level 3.1 -s 352X288 -an -y -t 10 output_baseline.ts
ffprobe -v quiet -show_frame -select_stream v output_baseline.ts | grep "pict_type=B"|wc -l
等于0ffmpeg -i input.mp4 -vcodec libx264 -profile:v high -level 3.1 -s 352X288 -an -y -t 10 output_high.ts
ffprobe -v quiet -show_frame -select_stream v output_high.ts | grep "pict_type=B"|wc -l
等于140ffmpeg -i input.mp4 -c:v libx264 -g 50 -sc_threshold 0 -t 60 -y output.mp4
ffmpeg -i input.mp4 -c:v libx264 -x264opts "bframes=0" -g 50 -sc_threshold 0 output.mp4
ffmpeg -i input.mp4 -c:v libx264 -x264opts "bframes=3:b-adapt=0" -g 50 -sc_threshold 0 output.mp4
ffmpeg -i input.mp4 -c:v libx264 -x264opts "bframes=10:b-adapt=0" -b:v 1000k -maxrate 1000k -minrate 1000k -buffsize 50k -nal-hrd cbr -g 50 -sc_threshold 0 output.ts
ffmpeg -h encoder=h264_nvenc
ffmpeg -hwaccel cuvid -vcodec h264_cuvid -i input.mp4 -vf scale_npp=1920:1080 -vcodec h264_nvenc -acodec copy -f mp4 -y output.mp4
ffmpeg -i 10M1080p.mp4 -pix_fmt nv12 -vcodec h264_qsv -an -y output.mp4
ffmpeg -hide_banner -y -hwaccel qsv -i 10M1080p.mp4 -an -c:v hevc_qsv -load_plugin hevc_hw -b:v 5M -maxrate 5M out.mp4
ffmpeg -i input.mp4 -vcodec h264_omx -b:v 500k -acodec copy -y output.mp4
ffmpeg -vcodec h264_vda -i input.mp4 -vcodec h264_videotoolbox -b:v 2000k output.mp4
ffmpeg -i input.mp3 -acodec libmp3lame -q:a 8 output.mp3
ffmpeg -i input.mp3 -acodec libmp3lame -b:a 64k output.mp3
ffmpeg -i input.mp3 -acodec libmp3lame -b:a 64k -abr 1 output.mp3
ffmpeg -rtmp_app live -i rtmp://publish.chinaffmpeg.com -c copy -f flv output.flv
ffmpeg -re -i input.mp4 -c copy -f flv -rtmp_app live rmtp://publish.chinaffmpeg.com
ffmpeg -re -i input.mp4 -c copy -f flv -rtmp_app live -rtmp_playpath class rtmp://publish.chinaffmpeg.com
./ffmpeg -rtmp_app live -rtmp_playpath class -i rtmp://publish.chinaffmpeg.com -c copy -f flv output.flv
./ffmpeg -i input.mp4 -c copy -f flv rtmp://publish.chinaffmpeg.com/live/class
./ffmpeg -i rtmp://publish.cinaffmpeg.com/live/class -c copy -f flv output.flv
./ffmpeg -rtsp_transport tcp -i rtsp://47.90.47.25/test.ts -c copy -f mp4 output.mp4
./ffmpeg -user-agent "ChinaFFmpeg-Play" -i rtsp://input:554/live/1/stream.sdp -c copy -f mp4 -y output.mp4
ffmpeg -ss 300 -seekable 0 -i http://bbs.chinaffmpeg.com/test.ts -c copy output.mp4
ffmpeg -ss 30 -seekable 1 -i http://bbs.chinaffmpeg.com/test.ts -c copy -y output.mp4
ffmpeg -headers "referer: http://bbs.chinaffmpeg.com/index.html" -i http://play.chinaffmpeg .com/live/class.flv -c copy -f flv -y output.flv
ffmpeg -user_agent "LiuQi's Player" -i http://bbs.chinaffmpeg.com/1.flv
ffmpeg -i http://bbs.chinaffmpeg.com/live.flv -c copy -f flv output.flv
ffmpeg -i http://bbs.chinaffmpeg.com/live.ts -c copy -f flv output.flv
ffmpeg -i http://chinaffmpeg.com/live.m3u8 -c copy -f flv output.flv
./ffmpeg -listen 1 -f flv -i tcp://127.0.0.1:1234/live/stream -c copy -f flv out.flv
./ffmpeg re -i input.mp4 -c copy -f flv tcp://127.0.0.1:1234/live/stream
time ./ffmpeg -listen_timeout 5000 -listen 1 -f flv -i tcp://127.0.0.1234/live/stream -c copy -f flv output.flv
time ./ffmpeg -timeout 20000000 -i tcp://192.168.100.179:1935/live/stream -c copy -f flv output.flv
./ffmpeg -re -i input.mp4 -c copy -send_buffer_size 265 -f flv tcp://192.168.100.179:1234/live/stream
./ffmpeg -re -i input.mp4 -c copy -localport 23456 -f flv udp://192.168.100.179:1234/live/stream
./ffmpeg -i input -acodec aac -vcodec libx264 -f flv - | ffmpeg -f mpegts -i - -c copy output1 -c copy output2 -c copy output3
./ffmpeg -i input.mp4 -vcodec libx264 -acodec aac -f flv - | ffmpeg -f flv -i - -c copy -f flv rtmp://publish.chinaffmpeg.com/live/stream1 -c copy -f flv rtmp://publish.chinaffmpeg.com/live/stream2
./ffmpeg -i rtmp://publish.chinaffmpeg.com/live/stream1 -i rtmp://publish.chinaffmpeg.com/live/stream2
-f tee
./ffmpeg -re -i input.mp4 -vcodec libx264 -acodec aac -map 0 -f tee "[f=flv]rtmp://publish.chinaffmpeg.com/live/stream1 | [f=flv]rtmp://publish.chinaffmpeg.com/live/stream2"
./ffmpeg -i rtmp://publish.chinaffmpeg.com/live/stream1 -i rtmp://publish.chinaffmpeg.com/live/stream2
./ffmpeg -re -i input.mp4 -vcodec libx264 -acodec aac -f flv "tee:rtmp://publish.chinaffmpeg.com/live/stream1 | rtmp://publish.chinaffmpeg.com/live/stream2"
./ffmpeg -i input -c copy -f hds -window_size 4 output
./ffmpeg -re -i input.mp4 -c:v copy -acodec copy -f dash -window_size 4 -extra_window_size 5 index.mpd
./ffmpeg -re -i input.mp4 -c:v copy -acodec copy -f dash -window_size 4 -extra_window_size 5 -sigle_file 1 index.mpd
1.ffmpeg 滤镜Filter描述格式
[输入流或标记名]滤镜参数[临时标记名]; [输入流或标记名]滤镜参数[临时标记名]...
滤镜参数以: , ;分割。./ffmpeg -i input.mp4 -i logo.png -filter_complex "[1:v]scale=176:144[logo];[0:v][logo]overlay=x=0:y=0" output.mp4
2.ffmpeg为视频加水印
./ffmpeg -i input.mp4 -vf "drawtext=fontsize=100:fontfile=FreeSerif.ttf:text='hello world':x=20:y=20" output.mp4
./ffmpeg -i input.mp4 -vf "drawtext=fontsize=100:fontfile=FreeSerif.ttf:text='hello world:fontcolor=green':x=20:y=20" output.mp4
./ffmpeg -i input.mp4 -vf "drawtext=fontsize=100:fontfile=FreeSerif.ttf:text='hello world':fontcolor=green:box=1:boxcolor=yellow" output.mp4
./ffmpeg -i input.mp4 -vf "drawtext=fontsize=60:fontfile=FreeSerif.ttf:text='%{localtime:\:%Y\-%m\-%d %H-%M-%S}':fontcolor=green:box=1:boxcolor=yellow" output.mp4
./ffmpeg -i input.mp4 -vf "drawtext=fontsize=60:fontfile=FreeSerif.ttf:text='test':fontcolor=green:box=1:boxcolor=yellow:enable=lt(mod(t\,3)\,1)" output.mp4
./ffmpeg -re -i input.mp4 -vf "drawtext=fontsize=50:fontfile=/Library/Fonts/Songti.ttc:text='文字水印测试':fontcolor=green:box=1:boxcolor=yellow" output.mp4
./ffmpeg -i input.mp4 -vf "movie=logo.png[wm];[in][wm]overlay=30:10[out]" out.mp4
x=30,y=10./ffmpeg -i input.mp4 -vf "movie=logo.png,colorkey=black:1.0:1.0[wm];[in][wm]overlay=30:10[out]" out.mp4
colorkey 设置得颜色值、相似度、混合度与原片混合为半透明水印。3.ffmpeg 生成画中画
./ffmpeg -re -i input.mp4 -vf "movie=sub.mp4,scale=480x320[test];[in][test]overlay[out]" -vcodec libx264 output.flv
默认x=0,y=0./ffmpeg -re -i input.mp4 -vf "movie=sub.mp4,scale=480x320[test];[in][test]overlay=x=main_w-480:y=main_h-320[out]" -vcodec libx264 output.flv
主画面右边减去子视频的宽度,主画面最下面减去子视频的高度./ffmpeg -re -i input.mp4 -vf "movie=sub.mp4,scale=480x320[test];[in][test]overlay=x='if(gte(t,2), -w+(t-2)*20,NAN)':y=0[out]" -vcodec libx264 output.flv
从左向右移动4.ffmpeg视频多宫格处理
./ffmpeg -re -i input1.mp4 -re -i input2.mp4 -re -i input3.m2t -re -i input4.mp4 -filter_complex "nullsrc=size=640x480 [base]; [0:v] setpts=PTS-STARTPTS,scale=320x240 [upperleft]; [1:v] setpts=PTS-STARTPTS,scale=320x240 [upperright]; [2:v] setpts=PTS-STARTPTS,scale=320x240 [lowerleft]; [3:v] setpts=PTS- STARTPTS,scale=320x240[lowerright]; [base][upperleft] overlay=shortest=1[tmp1]; [tmp1][upperright] overlay=shortest=1:x=320 [tmp2];[tmp2][lowerleft] overlay=shortest=1:y=240 [tmp3]; [tmp3][lowerright] overlay=shortest=1:x=320:y=240 -c:v libx264 output.flv
5 ffmpeg 音频流滤镜操作
./ffmpeg -i input.aac -ac 1 output.aac
./ffmpeg -i input.aac -map_channel 0.0.0 left.aac -map_channel 0.0.1 right.aac
map_channel 参数实现./ffmpeg -i input.aac -filter_complex "[0:0]pan=lc|c0=c0[left];[0:0]pan=lc|c0=c1[right]" -map "[left]" left.aac -map "[right]" right.aac
./ffmpeg -i input.aac -filter_complex channelsplit=channel_layout=stereo output.mka
./ffmpeg -i left.aac -ac 2 output.m4a
./ffmpeg -i left.aac -filter_complex "[0:a][0:a]amerge=inputs=2[aout]" -map "[aout]" output.m4a
./ffmpeg -i left.aac -i right.aac -filter_complex "[0:a][1:a]amerge=inputs=2[aout]" -map "[aout]" output.mka
./ffmpeg -i front_left.wav -i front_right.wav -i front_center.wav -i left.wav -i back_left.wav -i back_right.wav -filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a][6:a]amerge=inputs=6[aout]" -map "[aout]" output.wav
6.ffmpeg 音频音量探测
./ffmpeg -i output.wav -filter_complex volumedetect -c:v copy -f null /dev/null
./ffmpeg -i output.wav -filter_complex "showwavespic=s=640x120" -frames:v 1 output.png
./ffmpeg -i output.wav -filter_complex "showwavepic=s=640x240:split_channels=1" -frames:v 1 output:png
7.ffmpeg 为视频加字幕
./ffmpeg -i input.mp4 -vf ass=t1.ass -f mp4 output.mp4
./ffmpeg -i input.mp4 -i t1.ass -acodec copy -vcodec copy -scodec copy output.mkv
./ffmpeg -i input.mp4 -i t1.ass -map 0:0 -map 0:1 -map 1:0 -acodec copy -vcodec copy -scodec copy output.mkv
8.ffmpeg 视频抠图合并
./ffmpeg -i input.mp4 -i input_green.mp4 -filter_complex "[1:v]chromakey=Green:0.1:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mp4
图参看页数2059.FFmpeg 3D视频处理
./ffmpeg -vf "stereo3d=sbs1:aydb" input.mp4
./ffmpeg -vf "stereo3d=sbs1:arbg" input.mp4
,效果视频的宽度变小,图像的效果更具有立体感,带上红蓝眼镜观看处理效果更好。10.FFmpeg定时视频截图
./ffmpeg -i input.flv -ss 00:00:7.435 -vframes 1 out.png
./ffmpeg -i input.flv -vf fps=1 out%d.png
./ffmpeg -i input.flv -vf fps=1/60 img%03d.jpg
./ffmpeg -i input.flv -vf fps=1/600 thumb%04d.bmp
./ffmpeg -i input.flv -vf "select='eq(pict_type,PICT_TYPE_I)'" -vsync vfr thumb%04d.png
11.FFmpeg生成测试元数据
./ffmpeg -re -f lavfi -i abuffer=sample_rate=44100:sample_fmt=s16p:channel_layout=stereo -acodec aac -y output.aac
./ffmpeg -re -f lavfi "aevalsrc=sin(420*2*PI*t)|cos(430*2*PI*t):c=FC|BC" -acodec aac output.aac
./ffmpeg -re -f lavfi -i testsrc=duration=5.3:size=qcif:rate=25 -vcodec libx264 -r:v 25 output.mp4
./ffmpeg -re -f lavfi -i testsrc2=duration=5.3:size=qcif:rate=25 -vcodec libx264 -r:v 25 output.mp4
./ffmpeg -re -f lavfi -i [email protected]:s=qcif:r=25 -vcodec libx264 -r:v 25 output.mp4
./ffmpeg -re -f lavfi -i "nullsrc=s=256x256,geq=random(1)*255:128:128" -vcodec libx264 -r:v 25 output.mp4
宽高256x256 数据为随机雪花样12 FFmpeg对音视频倍速处理
./ffmpeg -i input.wav -filter_complex "atempo=tempo=0.5" -acodec aac output.aac
./ffmpeg -i input.wav -filter_complex "atempo=tempo=2.0" -acodec aac output.aac
./ffmpeg -re -i input.mp4 -filter_complex "setpts=PTS*2" output.mp4
./ffmpeg -re -i input.mp4 -filter_complex "setpts=PTS/2" output.mp4