5

I have got two video files: .mp4, with a single (incorrect) audiostream, and an .mkv, with two audio streams (one incorrect, the other correct)

Is there a way to replace the audio of the .mp4 file with the second stream in the .mkv?

Thanks

2

You'd need to extract the audio from the MKV first and then combine remux the MP4 with the new track. Something like this should work:

ffmpeg -i vid.mkv -acodec copy -vn audio.ext
ffmpeg -i vid.mp4 -i audio.ext -vcodec copy -acodec copy -map 0:1 -map 1:0 final.mp4
2
  • Hey, I extracted the audio properly using ffmpeg -i vid.mkv -map 0:2 -ac 2 aud.wav but still can't merge it with the mp4 file for some reason... – CookieMonster Aug 11 '11 at 11:37
  • Hi @CookieMonster. How was this resolved? – Nathan Apr 29 '18 at 2:40
2

Sure, with avconv (same as ffmpeg)

Try:

avconv -i INPUT_FILE_WITH_BROKEN_SOUND.mp4 -i SECOND_INPUT_FILE.mkv -c copy -map 0:v:0 -map 1:a:1 OUTPUT.mp4

-c copy copies tracks instead of re-encoding them

-map 0:v:0 selects track to be copied to output: 1st file -> video tracks -> 1st video track

-map 1:a:1 selects track to be copied to output: 2nd file -> audio tracks -> 2nd audio track

Hope it helps!

1
  • Could down-voter tell why it is wrong? – Mr. P Oct 20 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.