ffmpeg: 合并/合并多个mp4视频不工作
必须将它们转换为一个易于连接的MPEG格式。 下面是一个我使用的脚本,并调用"ffcat"作为GoPro视频。 它实际上运行几个"ffmpeg -i"命令,这些命令产生 concatenate-able MPEG,它被管道转换成一个ffmpeg命令,然后将它们转换成一个 H.264 mp4文件。
它还将视频大小调整为 720,但你可能不希望。
"h264options"是我最近在互联网上发现的标志 h264.code-shop.com
希望这能帮到你 Reid
cmd="("
h264options="-vcodec libx264 -b 512k -flags +loop+mv4 -cmp 256
-partitions +parti4x4+parti8x8+partp4x4+partp8x8+partb8x8
-me_method hex -subq 7 -trellis 1 -refs 5 -bf 3
-flags2 +bpyramid+wpred+mixed_refs+dct8x8 -coder 1 -me_range 16
-g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -qmin 10
-qmax 51 -qdiff 4"
outfile="out-`date +%F-%H%M.%S`.mp4"
for i; do
cmd="${cmd}ffmpeg -i $i -ab 256000 -vb 10000000 -mbd rd -trellis 2 -cmp 2 -subcmp 2 -g 100 -f mpeg -;"
done
cmd="${cmd} ) | ffmpeg -y -i - -threads 8 ${h264options} -vb 10000000 -acodec libfaac -ar 44100 -ab 128k -s 1280x720 ${outfile}"
echo"${cmd}"
eval ${cmd}
从ffmpeg手册页"范例"部分:
· You can put many streams of the same type in the output:
ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy
-vcodec copy -acodec copy test12.avi -newvideo -newaudio
In addition to the first video and audio streams, the resulting
output file test12.avi will contain the second video and the second
audio stream found in the input streams list.
The"-newvideo","-newaudio" and"-newsubtitle" options
have to be specified immediately after the name of the output file
to which you want to add them.