Replace audio stream from one file with audio stream from another
5,483
Solution 1
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
Solution 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!
Related videos on Youtube
Author by
CookieMonster
Updated on September 18, 2022Comments
-
CookieMonster over 1 year
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
-
CookieMonster over 12 yearsHey, 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... -
Mr. P over 8 yearsCould down-voter tell why it is wrong?
-
Nathan about 6 yearsHi @CookieMonster. How was this resolved?