我的ffmpeg常用命令
· 阅读需 4 分钟
我的 ffmpeg,ffprobe 常用命令
查看视频信息
ffprobe video.mp4
输出含义:
- tbn = the time base in AVStream that has come from the container
- tbc = the time base in AVCodecContext for the codec used for a particular stream
- tbr = tbr is guessed from the video stream and is the value users want to see when they look for the video frame rate
FFmpeg-users - What does the output of ffmpeg mean? tbr tbn tbc etc?
剪辑
ffmpeg -ss 0:0:4.000 -t 0:2:00 -i input.mp4 -vcodec copy -acodec copy out.mp4 #不重新编码
ffmpeg -ss 0:0:4.000 -t 0:2:00 -i input.mp4 -vcodec h264 -acodec aac out.mp4 #重新编码
指定间隔截图
ffmpeg -ss 00:00:10.000 -i sense8.S01E03.start.mp4 -vf fps=fps=10 ../screenshots/screen-%03d.jpg
# fps 后数值越大,截图越多
左右拼接
ffmpeg -i left.mp4 -i right.mp4 -filter_complex \
"[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w" output.mp4
合并
# 新版ffmpeg已经无法使用
ffmpeg -i "concat:input1.flv|input2.flv|input3.flv" -c copy output.mp4
# 通过文件来批量合并
ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4
# files.txt
file './1.mp4'
file './2.mp4'
file './3.mp4'
ffmpeg 压制带字幕视频
1280*640
ffmpeg -i input.mkv -map 0:0 -map 0:1 -c:a aac -ab 192k -strict -2 -async 1 -c:v libx264 -crf 23 -r 25 -s 1280x640 -aspect 2:1 -pix_fmt yuv420p -partitions partb8x8+partp4x4+partp8x8+parti8x8 -b-pyramid 1 -weightb 1 -8x8dct 1 -fast-pskip 1 -direct-pred 1 -coder ac -trellis 1 -me_method hex -subq 6 -me_range 16 -bf 3 -b_strategy 1 -refs 3 -flags +loop -sws_flags fast_bilinear -sc_threshold 40 -keyint_min 25 -g 50 -qmin 3 -qmax 51 -qdiff 4 -metadata creation_time=now -vf subtitles="sub.ass":charenc=utf-8 -sn -y output.mp4