Remove part of video only using command line (probably FFMPEG)












3















I have a 4 hour long .mp4 file and when I upload it to Youtube the entire audio track gets muted because of 30 seconds of some song between 01:21:47 and 01:22:24, how can I remove JUST this part of the video, or even better - just THIS part of the audio from the video?










share|improve this question





























    3















    I have a 4 hour long .mp4 file and when I upload it to Youtube the entire audio track gets muted because of 30 seconds of some song between 01:21:47 and 01:22:24, how can I remove JUST this part of the video, or even better - just THIS part of the audio from the video?










    share|improve this question



























      3












      3








      3


      1






      I have a 4 hour long .mp4 file and when I upload it to Youtube the entire audio track gets muted because of 30 seconds of some song between 01:21:47 and 01:22:24, how can I remove JUST this part of the video, or even better - just THIS part of the audio from the video?










      share|improve this question
















      I have a 4 hour long .mp4 file and when I upload it to Youtube the entire audio track gets muted because of 30 seconds of some song between 01:21:47 and 01:22:24, how can I remove JUST this part of the video, or even better - just THIS part of the audio from the video?







      ffmpeg






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 19 '18 at 10:59









      crmpicco

      2003415




      2003415










      asked Sep 11 '16 at 5:15









      CheronaCherona

      2015




      2015






















          2 Answers
          2






          active

          oldest

          votes


















          4














          If you are sure it's just that portion of the audio, then you can just mute it:



          ffmpeg -i input.mp4 -af volume=0:enable='between(t,01:21:47,01:22:24)' -c:v copy output.mp4


          Depending on your shell, you may have to escape the colons in the timecodes, or maybe switch to seconds representation (01:21:47 = 4907, 01:22:24 = 4944).






          share|improve this answer
























          • Hey thanks but here's what I came up with ffmpeg -i 88595331.mp4 -af volume=0:enable='between(t,4907,4944)' -c:v copy 88595331_v2.mp4 and the error i.imgur.com/aUogYcQ.png

            – Cherona
            Sep 11 '16 at 11:06













          • Try 'between(t,4907,4944)'

            – Gyan
            Sep 11 '16 at 11:10











          • seems to be working, thanks!

            – Cherona
            Sep 11 '16 at 11:13











          • Instead of doing this right now, first I suggest uploading just a trimmed portion and testing: ffmpeg -ss 01:21:47 -t 38 input.mp4 test.mp4

            – Gyan
            Sep 11 '16 at 11:19



















          0














          You can do this with an FFmpeg filtergraph.



          Try something along these lines:



          ffmpeg -i input.mp4 -filter_complex '[0:v] trim=end=01:21:47 [v1], [0:a] atrim=end=01:21:47 [a1], [0:v] trim=start=01:22:24 [v2], [0:a] atrim=start=01:22:24 [a2], [v1][a1][v2][a2] concat=n=2:v=1:a=1 [v][a]' -map '[v]' -map '[a]' output.mp4


          This particular filtergraph slices the input into four pieces: the initial video segment, the initial audio segment, the final video segment, and the final audio segment. Then it concatenates the video and audio segments together.



          See https://ffmpeg.org/ffmpeg-filters.html for more details on filtering.






          share|improve this answer



















          • 1





            Apart from the merits of re-encoding 4 hours of video just to mute a 30 second audio segment, this won't give the desired result because the concat filter requires all segments to have starting timestamps be 0. But the trim filters don't reset timestamps, so v2 and a2 will have non-zero timestamps and the concat filter won't behave predictably.

            – Gyan
            Sep 11 '16 at 7:16











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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%2fsuperuser.com%2fquestions%2f1123160%2fremove-part-of-video-only-using-command-line-probably-ffmpeg%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









          4














          If you are sure it's just that portion of the audio, then you can just mute it:



          ffmpeg -i input.mp4 -af volume=0:enable='between(t,01:21:47,01:22:24)' -c:v copy output.mp4


          Depending on your shell, you may have to escape the colons in the timecodes, or maybe switch to seconds representation (01:21:47 = 4907, 01:22:24 = 4944).






          share|improve this answer
























          • Hey thanks but here's what I came up with ffmpeg -i 88595331.mp4 -af volume=0:enable='between(t,4907,4944)' -c:v copy 88595331_v2.mp4 and the error i.imgur.com/aUogYcQ.png

            – Cherona
            Sep 11 '16 at 11:06













          • Try 'between(t,4907,4944)'

            – Gyan
            Sep 11 '16 at 11:10











          • seems to be working, thanks!

            – Cherona
            Sep 11 '16 at 11:13











          • Instead of doing this right now, first I suggest uploading just a trimmed portion and testing: ffmpeg -ss 01:21:47 -t 38 input.mp4 test.mp4

            – Gyan
            Sep 11 '16 at 11:19
















          4














          If you are sure it's just that portion of the audio, then you can just mute it:



          ffmpeg -i input.mp4 -af volume=0:enable='between(t,01:21:47,01:22:24)' -c:v copy output.mp4


          Depending on your shell, you may have to escape the colons in the timecodes, or maybe switch to seconds representation (01:21:47 = 4907, 01:22:24 = 4944).






          share|improve this answer
























          • Hey thanks but here's what I came up with ffmpeg -i 88595331.mp4 -af volume=0:enable='between(t,4907,4944)' -c:v copy 88595331_v2.mp4 and the error i.imgur.com/aUogYcQ.png

            – Cherona
            Sep 11 '16 at 11:06













          • Try 'between(t,4907,4944)'

            – Gyan
            Sep 11 '16 at 11:10











          • seems to be working, thanks!

            – Cherona
            Sep 11 '16 at 11:13











          • Instead of doing this right now, first I suggest uploading just a trimmed portion and testing: ffmpeg -ss 01:21:47 -t 38 input.mp4 test.mp4

            – Gyan
            Sep 11 '16 at 11:19














          4












          4








          4







          If you are sure it's just that portion of the audio, then you can just mute it:



          ffmpeg -i input.mp4 -af volume=0:enable='between(t,01:21:47,01:22:24)' -c:v copy output.mp4


          Depending on your shell, you may have to escape the colons in the timecodes, or maybe switch to seconds representation (01:21:47 = 4907, 01:22:24 = 4944).






          share|improve this answer













          If you are sure it's just that portion of the audio, then you can just mute it:



          ffmpeg -i input.mp4 -af volume=0:enable='between(t,01:21:47,01:22:24)' -c:v copy output.mp4


          Depending on your shell, you may have to escape the colons in the timecodes, or maybe switch to seconds representation (01:21:47 = 4907, 01:22:24 = 4944).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 11 '16 at 7:04









          GyanGyan

          14.7k21845




          14.7k21845













          • Hey thanks but here's what I came up with ffmpeg -i 88595331.mp4 -af volume=0:enable='between(t,4907,4944)' -c:v copy 88595331_v2.mp4 and the error i.imgur.com/aUogYcQ.png

            – Cherona
            Sep 11 '16 at 11:06













          • Try 'between(t,4907,4944)'

            – Gyan
            Sep 11 '16 at 11:10











          • seems to be working, thanks!

            – Cherona
            Sep 11 '16 at 11:13











          • Instead of doing this right now, first I suggest uploading just a trimmed portion and testing: ffmpeg -ss 01:21:47 -t 38 input.mp4 test.mp4

            – Gyan
            Sep 11 '16 at 11:19



















          • Hey thanks but here's what I came up with ffmpeg -i 88595331.mp4 -af volume=0:enable='between(t,4907,4944)' -c:v copy 88595331_v2.mp4 and the error i.imgur.com/aUogYcQ.png

            – Cherona
            Sep 11 '16 at 11:06













          • Try 'between(t,4907,4944)'

            – Gyan
            Sep 11 '16 at 11:10











          • seems to be working, thanks!

            – Cherona
            Sep 11 '16 at 11:13











          • Instead of doing this right now, first I suggest uploading just a trimmed portion and testing: ffmpeg -ss 01:21:47 -t 38 input.mp4 test.mp4

            – Gyan
            Sep 11 '16 at 11:19

















          Hey thanks but here's what I came up with ffmpeg -i 88595331.mp4 -af volume=0:enable='between(t,4907,4944)' -c:v copy 88595331_v2.mp4 and the error i.imgur.com/aUogYcQ.png

          – Cherona
          Sep 11 '16 at 11:06







          Hey thanks but here's what I came up with ffmpeg -i 88595331.mp4 -af volume=0:enable='between(t,4907,4944)' -c:v copy 88595331_v2.mp4 and the error i.imgur.com/aUogYcQ.png

          – Cherona
          Sep 11 '16 at 11:06















          Try 'between(t,4907,4944)'

          – Gyan
          Sep 11 '16 at 11:10





          Try 'between(t,4907,4944)'

          – Gyan
          Sep 11 '16 at 11:10













          seems to be working, thanks!

          – Cherona
          Sep 11 '16 at 11:13





          seems to be working, thanks!

          – Cherona
          Sep 11 '16 at 11:13













          Instead of doing this right now, first I suggest uploading just a trimmed portion and testing: ffmpeg -ss 01:21:47 -t 38 input.mp4 test.mp4

          – Gyan
          Sep 11 '16 at 11:19





          Instead of doing this right now, first I suggest uploading just a trimmed portion and testing: ffmpeg -ss 01:21:47 -t 38 input.mp4 test.mp4

          – Gyan
          Sep 11 '16 at 11:19













          0














          You can do this with an FFmpeg filtergraph.



          Try something along these lines:



          ffmpeg -i input.mp4 -filter_complex '[0:v] trim=end=01:21:47 [v1], [0:a] atrim=end=01:21:47 [a1], [0:v] trim=start=01:22:24 [v2], [0:a] atrim=start=01:22:24 [a2], [v1][a1][v2][a2] concat=n=2:v=1:a=1 [v][a]' -map '[v]' -map '[a]' output.mp4


          This particular filtergraph slices the input into four pieces: the initial video segment, the initial audio segment, the final video segment, and the final audio segment. Then it concatenates the video and audio segments together.



          See https://ffmpeg.org/ffmpeg-filters.html for more details on filtering.






          share|improve this answer



















          • 1





            Apart from the merits of re-encoding 4 hours of video just to mute a 30 second audio segment, this won't give the desired result because the concat filter requires all segments to have starting timestamps be 0. But the trim filters don't reset timestamps, so v2 and a2 will have non-zero timestamps and the concat filter won't behave predictably.

            – Gyan
            Sep 11 '16 at 7:16
















          0














          You can do this with an FFmpeg filtergraph.



          Try something along these lines:



          ffmpeg -i input.mp4 -filter_complex '[0:v] trim=end=01:21:47 [v1], [0:a] atrim=end=01:21:47 [a1], [0:v] trim=start=01:22:24 [v2], [0:a] atrim=start=01:22:24 [a2], [v1][a1][v2][a2] concat=n=2:v=1:a=1 [v][a]' -map '[v]' -map '[a]' output.mp4


          This particular filtergraph slices the input into four pieces: the initial video segment, the initial audio segment, the final video segment, and the final audio segment. Then it concatenates the video and audio segments together.



          See https://ffmpeg.org/ffmpeg-filters.html for more details on filtering.






          share|improve this answer



















          • 1





            Apart from the merits of re-encoding 4 hours of video just to mute a 30 second audio segment, this won't give the desired result because the concat filter requires all segments to have starting timestamps be 0. But the trim filters don't reset timestamps, so v2 and a2 will have non-zero timestamps and the concat filter won't behave predictably.

            – Gyan
            Sep 11 '16 at 7:16














          0












          0








          0







          You can do this with an FFmpeg filtergraph.



          Try something along these lines:



          ffmpeg -i input.mp4 -filter_complex '[0:v] trim=end=01:21:47 [v1], [0:a] atrim=end=01:21:47 [a1], [0:v] trim=start=01:22:24 [v2], [0:a] atrim=start=01:22:24 [a2], [v1][a1][v2][a2] concat=n=2:v=1:a=1 [v][a]' -map '[v]' -map '[a]' output.mp4


          This particular filtergraph slices the input into four pieces: the initial video segment, the initial audio segment, the final video segment, and the final audio segment. Then it concatenates the video and audio segments together.



          See https://ffmpeg.org/ffmpeg-filters.html for more details on filtering.






          share|improve this answer













          You can do this with an FFmpeg filtergraph.



          Try something along these lines:



          ffmpeg -i input.mp4 -filter_complex '[0:v] trim=end=01:21:47 [v1], [0:a] atrim=end=01:21:47 [a1], [0:v] trim=start=01:22:24 [v2], [0:a] atrim=start=01:22:24 [a2], [v1][a1][v2][a2] concat=n=2:v=1:a=1 [v][a]' -map '[v]' -map '[a]' output.mp4


          This particular filtergraph slices the input into four pieces: the initial video segment, the initial audio segment, the final video segment, and the final audio segment. Then it concatenates the video and audio segments together.



          See https://ffmpeg.org/ffmpeg-filters.html for more details on filtering.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 11 '16 at 5:23









          Leo IzenLeo Izen

          12918




          12918








          • 1





            Apart from the merits of re-encoding 4 hours of video just to mute a 30 second audio segment, this won't give the desired result because the concat filter requires all segments to have starting timestamps be 0. But the trim filters don't reset timestamps, so v2 and a2 will have non-zero timestamps and the concat filter won't behave predictably.

            – Gyan
            Sep 11 '16 at 7:16














          • 1





            Apart from the merits of re-encoding 4 hours of video just to mute a 30 second audio segment, this won't give the desired result because the concat filter requires all segments to have starting timestamps be 0. But the trim filters don't reset timestamps, so v2 and a2 will have non-zero timestamps and the concat filter won't behave predictably.

            – Gyan
            Sep 11 '16 at 7:16








          1




          1





          Apart from the merits of re-encoding 4 hours of video just to mute a 30 second audio segment, this won't give the desired result because the concat filter requires all segments to have starting timestamps be 0. But the trim filters don't reset timestamps, so v2 and a2 will have non-zero timestamps and the concat filter won't behave predictably.

          – Gyan
          Sep 11 '16 at 7:16





          Apart from the merits of re-encoding 4 hours of video just to mute a 30 second audio segment, this won't give the desired result because the concat filter requires all segments to have starting timestamps be 0. But the trim filters don't reset timestamps, so v2 and a2 will have non-zero timestamps and the concat filter won't behave predictably.

          – Gyan
          Sep 11 '16 at 7:16


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • 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%2fsuperuser.com%2fquestions%2f1123160%2fremove-part-of-video-only-using-command-line-probably-ffmpeg%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

          Сан-Квентин

          8-я гвардейская общевойсковая армия

          Алькесар