演示环境:CentOS 7
下载视频文件:
[root@localhost ~]# wget http://he.yinyuetai.com/uploads/videos/common/CDF2014EE2B807C14EB06DDFA6A9D362.flv [root@localhost ~]# wget http://sh.yinyuetai.com/uploads/videos/common/3A37014EE2B807B94477C00DCB8A246D.mp4 [root@localhost ~]# md5sum CDF2014EE2B807C14EB06DDFA6A9D362.flv 14cc9847a0c6e458e49a62429248600a CDF2014EE2B807C14EB06DDFA6A9D362.flv [root@localhost ~]# md5sum 3A37014EE2B807B94477C00DCB8A246D.mp4 15bb143a0fe8ffec045eef75bc0fa4c9 3A37014EE2B807B94477C00DCB8A246D.mp4 [root@localhost ~]# [root@localhost ~]# mv CDF2014EE2B807C14EB06DDFA6A9D362.flv Cry_Cry_T-ara_720p.flv [root@localhost ~]# mv 3A37014EE2B807B94477C00DCB8A246D.mp4 Cry_Cry_T-ara_1080p.mp4 [root@localhost ~]# file Cry_Cry_T-ara_* Cry_Cry_T-ara_1080p.mp4: ISO Media, MPEG v4 system, version 1 Cry_Cry_T-ara_720p.flv: ISO Media, MPEG v4 system, version 1 [root@localhost ~]#
编译安装ffmpeg,如果已经安装,请跳过此步骤。
[root@localhost ~]# wget https://github.com/FFmpeg/FFmpeg/archive/n3.1.10.tar.gz [root@localhost ~]# tar xf n3.1.10.tar.gz [root@localhost ~]# cd FFmpeg-n3.1.10/ [root@localhost FFmpeg-n3.1.10]# ./configure --disable-debug && make -j 8 && make install [root@localhost FFmpeg-n3.1.10]# echo $? 0
开始使用ffmpeg,合并视频
FFmpeg concat 视频合并
这种方法成功率很高,也是最好的。先创建一个文本文件list_720p.txt
[root@localhost ~]# cat list_720p.txt file ‘Cry_Cry_T-ara_720p.flv‘ file ‘Cry_Cry_T-ara_720p.flv‘ file ‘Cry_Cry_T-ara_720p.flv‘ file ‘Cry_Cry_T-ara_720p.flv‘ file ‘Cry_Cry_T-ara_720p.flv‘ [root@localhost ~]#
然后: ffmpeg -f concat -i ./list_720p.txt -ccopy Collection_720p.mp4 如果 list_720p.txt 里面的视频文件内容不一样,比如音视频编码不一样,帧率码流分辨率不一样, 还想合成一个文件,那就要设置相关参数了。 或者可以这样,设置视频编码,设置音频编码,设置帧率(还可以设置码流) ffmpeg -f concat -i ./list_720p.txt -vcodec h264 -acodec aac -r 30 Collection_720p.mp4
本文出自 “李春利” 博客,转载请与作者联系!
原文地址:http://990487026.blog.51cto.com/10133282/1958562