演示环境:CentOS 7
下载视频文件:
[[email protected] ~]# wget http://he.yinyuetai.com/uploads/videos/common/CDF2014EE2B807C14EB06DDFA6A9D362.flv [[email protected] ~]# wget http://sh.yinyuetai.com/uploads/videos/common/3A37014EE2B807B94477C00DCB8A246D.mp4 [[email protected] ~]# md5sum CDF2014EE2B807C14EB06DDFA6A9D362.flv 14cc9847a0c6e458e49a62429248600a CDF2014EE2B807C14EB06DDFA6A9D362.flv [[email protected] ~]# md5sum 3A37014EE2B807B94477C00DCB8A246D.mp4 15bb143a0fe8ffec045eef75bc0fa4c9 3A37014EE2B807B94477C00DCB8A246D.mp4 [[email protected] ~]# [[email protected] ~]# mv CDF2014EE2B807C14EB06DDFA6A9D362.flv Cry_Cry_T-ara_720p.flv [[email protected] ~]# mv 3A37014EE2B807B94477C00DCB8A246D.mp4 Cry_Cry_T-ara_1080p.mp4 [[email protected] ~]# 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 [[email protected] ~]#
编译安装ffmpeg,如果已经安装,请跳过此步骤。
[[email protected] ~]# wget https://github.com/FFmpeg/FFmpeg/archive/n3.1.10.tar.gz [[email protected] ~]# tar xf n3.1.10.tar.gz [[email protected] ~]# cd FFmpeg-n3.1.10/ [[email protected] FFmpeg-n3.1.10]# ./configure --disable-debug && make -j 8 && make install [[email protected] FFmpeg-n3.1.10]# echo $? 0
开始使用ffmpeg,合并视频
FFmpeg concat 视频合并
这种方法成功率很高,也是最好的。先创建一个文本文件list_720p.txt
[[email protected] ~]# 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‘ [[email protected] ~]#
然后: 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
时间: 2024-10-15 01:03:34