combine video files by ffmpeg

Suppose you have a chain of video files, such as 1.mp4, 2.mp4, 3.mp4 and etc. They should be one video file but were cut into small video fragments.

You can use ffmpeg tool to combine them. And for convenience, I wrote a shell script to do these stuff.

concat=""
count=10
for i in`seq count` 
do
if [ ${i} -eq ${number} ];then concat=${concat}"/Users/BlueCocoa/Desktop/us/Nico/2/tmp/${i}.mpg"
else
concat=${concat}"/Users/BlueCocoa/Desktop/us/Nico/2/tmp/${i}.mpg|"
fi
ffmpeg -i ~/${i}.mp4 -f mpeg -r 29.97 ~/tmp/${i}.mpg
done
ffmpeg -i concat:${concat} -vcodec copy -acodec copy ~/tmp.mpg
ffmpeg -i ~/tmp.mpg -strict -2 -vcodec h264 -acodec aac ~/combined.mp4
rm ~/tmp.mpg
rm -rf ~/tmp
echo "Done!"

声明: 本文为0xBBC原创, 转载注明出处喵~

发表评论

电子邮件地址不会被公开。 必填项已用*标注