简体   繁体   中英

How to combine 2 video files and audio file with FFMPEG?

I am attempting to use ffmpeg exe to combine 2 video files and 1 audio. I wanted the audio to play over " inputFile.mp4 " and not over the " outroFile.mp4 " is this possible? Currently this is what I have. But Im not sure if what im doing wrong or what I need to get it right.

ffmpeg -i "inputFile.mp4" -i "outroFile.mp4" -i "audioFile.mp3" -threads 4 -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] [2:v:0] [2:a:0] concat=n=3:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" "outputFile.mp4" 

Can you please help me with this?

This can be done in two steps.

#1

ffmpeg -i "inputFile.mp4" -stream_loop -1 -i "audioFile.mp3" -map 0:v -map 1:a -c copy -shortest inputwithaudio.mp4

#2

ffmpeg -i inputwithaudio.mp4 -i outrofile.mp4 -threads 4 -filter_complex "[0:v:0] [0:a:0] [1:v:0] [1:a:0] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" "outputFile.mp4"

You'll need a recent version of ffmpeg, preferably 4.0, as there's a bug with stream_loop in earlir versions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM