Use FFMPEG to combine MP4 and MP3 file?
I have two files, video.mp4 and genaudio.mp3 (both same length). How can I merge the MP3 file with the MP4 using FFMPEG (or any command line program)?
This is what I have so far, but it doesn't replace the audio after spitting it out:
ffmpeg -i video.mp4 -i genaudio.mp3 -c:v copy -c:a mp3 output.mp4 -y
Solution 1:
You'll have to map the input streams:
ffmpeg -i video.mp4 -i genaudio.mp3 -map 0:v -map 1:a -c:v copy -c:a copy output.mp4 -y
When the inputs have multiple streams of a type among them, ffmpeg picks the 'best' one. For audio, that's the one with most number of channels. If those are the same, then it picks a stream from the earliest input.
(No need to re-encode the audio, so I've switched to copy)