FFmpeg命令

0

MKV转MP4

# 很慢
/usr/local/ffmpeg/bin/ffmpeg -i source.mkv -vcodec h264 target.mp4
/usr/local/ffmpeg/bin/ffmpeg -i source.mkv -c copy target.mp4
# 音频
/usr/local/ffmpeg/bin/ffmpeg -i source.mkv -vcodec copy -acodec aac target.mp4

-y 默认覆盖

由于录制媒体流时直接使用-c copy所以导致数据之中很多的重传的错包,所以需要有些特殊处理。

Too many packets buffered for output stream 0:1.
[aac @ 0x24a2100] Qavg: 61578.551
[aac @ 0x24a2100] 2 frames left in the queue on closing
Conversion failed!

添加参数-threads 2max_muxing_queue_size 1024

ffmpeg -threads 2 -i 000000.ts -max_muxing_queue_size 1024 -c:a aac -c:v h264 video.mp4
[aac @ 0x2290a80] Too many bits 8832.000000 > 6144 per frame requested, clamping to max
[mp4 @ 0x2102d40] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
[libx264 @ 0x20c9380] MB rate (121500000) > level limit (16711680)
...
More than 1000 frames duplicated

添加参数-vsync 2

ffmpeg -i 000000.ts -vsync 2 -c:a aac -c:v h264 video.mp4