Replace audio stream from one file with audio stream from another












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










share|improve this question



























    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










    share|improve this question

























      5












      5








      5


      1






      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










      share|improve this question














      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







      sound video conversion






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 10 '11 at 22:53









      CookieMonsterCookieMonster

      16025




      16025






















          2 Answers
          2






          active

          oldest

          votes


















          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





          share|improve this answer
























          • 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?

            – frank
            Apr 29 '18 at 2:40



















          1














          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!






          share|improve this answer


























          • Could down-voter tell why it is wrong?

            – Mr. P
            Oct 20 '15 at 11:46











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f56638%2freplace-audio-stream-from-one-file-with-audio-stream-from-another%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          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





          share|improve this answer
























          • 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?

            – frank
            Apr 29 '18 at 2:40
















          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





          share|improve this answer
























          • 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?

            – frank
            Apr 29 '18 at 2:40














          2












          2








          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





          share|improve this answer













          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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 10 '11 at 23:02









          OliOli

          221k86561763




          221k86561763













          • 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?

            – frank
            Apr 29 '18 at 2:40



















          • 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?

            – frank
            Apr 29 '18 at 2:40

















          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





          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?

          – frank
          Apr 29 '18 at 2:40





          Hi @CookieMonster. How was this resolved?

          – frank
          Apr 29 '18 at 2:40













          1














          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!






          share|improve this answer


























          • Could down-voter tell why it is wrong?

            – Mr. P
            Oct 20 '15 at 11:46
















          1














          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!






          share|improve this answer


























          • Could down-voter tell why it is wrong?

            – Mr. P
            Oct 20 '15 at 11:46














          1












          1








          1







          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!






          share|improve this answer















          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!







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 12 at 16:31

























          answered Sep 22 '15 at 11:08









          Mr. PMr. P

          1305




          1305













          • Could down-voter tell why it is wrong?

            – Mr. P
            Oct 20 '15 at 11:46



















          • Could down-voter tell why it is wrong?

            – Mr. P
            Oct 20 '15 at 11:46

















          Could down-voter tell why it is wrong?

          – Mr. P
          Oct 20 '15 at 11:46





          Could down-voter tell why it is wrong?

          – Mr. P
          Oct 20 '15 at 11:46


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f56638%2freplace-audio-stream-from-one-file-with-audio-stream-from-another%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mouse cursor on multiple screens with different PPI

          Agildo Ribeiro

          Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”