Overlay first seconds of a video over the last seconds of the same video





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'd like to do the following with ffmpeg :



Replace the last n seconds of a video with the first n seconds of this same video. Those first n seconds would have to appear fading in.



To clarify, if n = 2 :




  • Take the first 2 seconds, remove them from the beginning of the video.

  • Overlay those 2 seconds on the last 2 seconds of the video, fading in (fade in time would also be n.


I have tried this command :



ffmpeg -i media.mp4 -filter_complex "[0:v]trim=00:02,setpts=PTS-STARTPTS[v0]; [0:v]trim=02:10,setpts=PTS-STARTPTS[v1]; [v0][v1]concat=n=2:v=1:a=0[out]" -map "[out]" output.mp4


which has absolutely no effect, output file is the same as my input file.



Any help ?



Thanks !










share|improve this question





























    0















    I'd like to do the following with ffmpeg :



    Replace the last n seconds of a video with the first n seconds of this same video. Those first n seconds would have to appear fading in.



    To clarify, if n = 2 :




    • Take the first 2 seconds, remove them from the beginning of the video.

    • Overlay those 2 seconds on the last 2 seconds of the video, fading in (fade in time would also be n.


    I have tried this command :



    ffmpeg -i media.mp4 -filter_complex "[0:v]trim=00:02,setpts=PTS-STARTPTS[v0]; [0:v]trim=02:10,setpts=PTS-STARTPTS[v1]; [v0][v1]concat=n=2:v=1:a=0[out]" -map "[out]" output.mp4


    which has absolutely no effect, output file is the same as my input file.



    Any help ?



    Thanks !










    share|improve this question

























      0












      0








      0








      I'd like to do the following with ffmpeg :



      Replace the last n seconds of a video with the first n seconds of this same video. Those first n seconds would have to appear fading in.



      To clarify, if n = 2 :




      • Take the first 2 seconds, remove them from the beginning of the video.

      • Overlay those 2 seconds on the last 2 seconds of the video, fading in (fade in time would also be n.


      I have tried this command :



      ffmpeg -i media.mp4 -filter_complex "[0:v]trim=00:02,setpts=PTS-STARTPTS[v0]; [0:v]trim=02:10,setpts=PTS-STARTPTS[v1]; [v0][v1]concat=n=2:v=1:a=0[out]" -map "[out]" output.mp4


      which has absolutely no effect, output file is the same as my input file.



      Any help ?



      Thanks !










      share|improve this question














      I'd like to do the following with ffmpeg :



      Replace the last n seconds of a video with the first n seconds of this same video. Those first n seconds would have to appear fading in.



      To clarify, if n = 2 :




      • Take the first 2 seconds, remove them from the beginning of the video.

      • Overlay those 2 seconds on the last 2 seconds of the video, fading in (fade in time would also be n.


      I have tried this command :



      ffmpeg -i media.mp4 -filter_complex "[0:v]trim=00:02,setpts=PTS-STARTPTS[v0]; [0:v]trim=02:10,setpts=PTS-STARTPTS[v1]; [v0][v1]concat=n=2:v=1:a=0[out]" -map "[out]" output.mp4


      which has absolutely no effect, output file is the same as my input file.



      Any help ?



      Thanks !







      ffmpeg






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 12 at 14:03









      michelmichel

      1




      1






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Use



          ffmpeg -i media.mp4 -filter_complex "[0:v]trim=0:n,setpts=PTS-STARTPTS,fade=st=0:d=n,format=yuva420p[v0]; [0:v]trim=n,format=yuva420p,colorchannelmixer=aa=0,setpts=PTS-STARTPTS[v1]; [v1][v0]concat=n=2:v=1:a=0[ol];[0:v]overlay,trim=n,setpts=PTS-STARTPTS[out]" -map "[out]" output.mp4



          The first n seconds are extracted and have a fade applied and an opaque alpha channel added. The remainder of the video has a transparent alpha channel added. The first portion is appended to the 2nd one. This whole stream is then overlaid on the full original video stream. The portion of the overlay with transparent alpha is invisble so the base video shows through, but the last n seconds of the overlay, which is, in fact, the first n seconds the video but with fade applied, is overlaid on the last n seconds of the base video.






          share|improve this answer


























          • Why should the OP use this command? What does it do?

            – Burgi
            Mar 12 at 16:22











          • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

            – Burgi
            Mar 12 at 16:22











          • @Burgi added explanation. It always provided an answer to the question.

            – Gyan
            Mar 12 at 17:23












          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%2f1413405%2foverlay-first-seconds-of-a-video-over-the-last-seconds-of-the-same-video%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Use



          ffmpeg -i media.mp4 -filter_complex "[0:v]trim=0:n,setpts=PTS-STARTPTS,fade=st=0:d=n,format=yuva420p[v0]; [0:v]trim=n,format=yuva420p,colorchannelmixer=aa=0,setpts=PTS-STARTPTS[v1]; [v1][v0]concat=n=2:v=1:a=0[ol];[0:v]overlay,trim=n,setpts=PTS-STARTPTS[out]" -map "[out]" output.mp4



          The first n seconds are extracted and have a fade applied and an opaque alpha channel added. The remainder of the video has a transparent alpha channel added. The first portion is appended to the 2nd one. This whole stream is then overlaid on the full original video stream. The portion of the overlay with transparent alpha is invisble so the base video shows through, but the last n seconds of the overlay, which is, in fact, the first n seconds the video but with fade applied, is overlaid on the last n seconds of the base video.






          share|improve this answer


























          • Why should the OP use this command? What does it do?

            – Burgi
            Mar 12 at 16:22











          • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

            – Burgi
            Mar 12 at 16:22











          • @Burgi added explanation. It always provided an answer to the question.

            – Gyan
            Mar 12 at 17:23
















          1














          Use



          ffmpeg -i media.mp4 -filter_complex "[0:v]trim=0:n,setpts=PTS-STARTPTS,fade=st=0:d=n,format=yuva420p[v0]; [0:v]trim=n,format=yuva420p,colorchannelmixer=aa=0,setpts=PTS-STARTPTS[v1]; [v1][v0]concat=n=2:v=1:a=0[ol];[0:v]overlay,trim=n,setpts=PTS-STARTPTS[out]" -map "[out]" output.mp4



          The first n seconds are extracted and have a fade applied and an opaque alpha channel added. The remainder of the video has a transparent alpha channel added. The first portion is appended to the 2nd one. This whole stream is then overlaid on the full original video stream. The portion of the overlay with transparent alpha is invisble so the base video shows through, but the last n seconds of the overlay, which is, in fact, the first n seconds the video but with fade applied, is overlaid on the last n seconds of the base video.






          share|improve this answer


























          • Why should the OP use this command? What does it do?

            – Burgi
            Mar 12 at 16:22











          • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

            – Burgi
            Mar 12 at 16:22











          • @Burgi added explanation. It always provided an answer to the question.

            – Gyan
            Mar 12 at 17:23














          1












          1








          1







          Use



          ffmpeg -i media.mp4 -filter_complex "[0:v]trim=0:n,setpts=PTS-STARTPTS,fade=st=0:d=n,format=yuva420p[v0]; [0:v]trim=n,format=yuva420p,colorchannelmixer=aa=0,setpts=PTS-STARTPTS[v1]; [v1][v0]concat=n=2:v=1:a=0[ol];[0:v]overlay,trim=n,setpts=PTS-STARTPTS[out]" -map "[out]" output.mp4



          The first n seconds are extracted and have a fade applied and an opaque alpha channel added. The remainder of the video has a transparent alpha channel added. The first portion is appended to the 2nd one. This whole stream is then overlaid on the full original video stream. The portion of the overlay with transparent alpha is invisble so the base video shows through, but the last n seconds of the overlay, which is, in fact, the first n seconds the video but with fade applied, is overlaid on the last n seconds of the base video.






          share|improve this answer















          Use



          ffmpeg -i media.mp4 -filter_complex "[0:v]trim=0:n,setpts=PTS-STARTPTS,fade=st=0:d=n,format=yuva420p[v0]; [0:v]trim=n,format=yuva420p,colorchannelmixer=aa=0,setpts=PTS-STARTPTS[v1]; [v1][v0]concat=n=2:v=1:a=0[ol];[0:v]overlay,trim=n,setpts=PTS-STARTPTS[out]" -map "[out]" output.mp4



          The first n seconds are extracted and have a fade applied and an opaque alpha channel added. The remainder of the video has a transparent alpha channel added. The first portion is appended to the 2nd one. This whole stream is then overlaid on the full original video stream. The portion of the overlay with transparent alpha is invisble so the base video shows through, but the last n seconds of the overlay, which is, in fact, the first n seconds the video but with fade applied, is overlaid on the last n seconds of the base video.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 12 at 17:16

























          answered Mar 12 at 14:27









          GyanGyan

          15.9k21848




          15.9k21848













          • Why should the OP use this command? What does it do?

            – Burgi
            Mar 12 at 16:22











          • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

            – Burgi
            Mar 12 at 16:22











          • @Burgi added explanation. It always provided an answer to the question.

            – Gyan
            Mar 12 at 17:23



















          • Why should the OP use this command? What does it do?

            – Burgi
            Mar 12 at 16:22











          • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

            – Burgi
            Mar 12 at 16:22











          • @Burgi added explanation. It always provided an answer to the question.

            – Gyan
            Mar 12 at 17:23

















          Why should the OP use this command? What does it do?

          – Burgi
          Mar 12 at 16:22





          Why should the OP use this command? What does it do?

          – Burgi
          Mar 12 at 16:22













          This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

          – Burgi
          Mar 12 at 16:22





          This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review

          – Burgi
          Mar 12 at 16:22













          @Burgi added explanation. It always provided an answer to the question.

          – Gyan
          Mar 12 at 17:23





          @Burgi added explanation. It always provided an answer to the question.

          – Gyan
          Mar 12 at 17:23


















          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%2f1413405%2foverlay-first-seconds-of-a-video-over-the-last-seconds-of-the-same-video%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

          Probability when a professor distributes a quiz and homework assignment to a class of n students.

          Aardman Animations

          Are they similar matrix