ffmpeg: 合并/合并多个mp4视频不工作

本文提供了一个使用FFmpeg合并多个MP4视频的脚本示例。通过将视频转换为可连接的MPEG格式,再利用ffcat工具进行连接,最终输出为H.264编码的mp4文件。文中还介绍了如何调整视频分辨率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值