How to add a png logo to mp4 video with ffmpeg which can be resize dynamically and cover the whole video












0














I want to show a logoon a video when the video starts. I already found this command :



ffmpeg -i input.mp4 -framerate 30000/1001 
-loop 1 -i test.png -filter_complex "[1:v] fade=out:st=30:d=1:alpha=1 [ov];
[0:v][ov] overlay=10:10 [v]" -map "[v]" -map 0:a -c:v libx264
-c:a copy -shortest Bigout.mp4


from
How to add my logo for the first 30 seconds in a video with ffmpeg?



But the problem is my video's widths/heights are different and each time I add a logo, it does not cover the whole video. What should I do if I want to set the logo width/height to the width/height of the video ?



UPDATE
After @Behroozfar Answer, I tried to use scale2ref, with the command below:



ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i biglogo.png -filter_complex "[1:v][0:v]scale2ref=iw/1:-1[ovrl][0v]; [0v][ovrl]overlay=0:0[v]" -map "[v] ; [1:v] fade=out:st=2:d=1:alpha=1 [ov]" -map 0:a -c:v libx264 -c:a copy -shortest Bigout.mp4



but the question is , I can't show the logo just for one second. It exists during the whole video play.










share|improve this question





























    0














    I want to show a logoon a video when the video starts. I already found this command :



    ffmpeg -i input.mp4 -framerate 30000/1001 
    -loop 1 -i test.png -filter_complex "[1:v] fade=out:st=30:d=1:alpha=1 [ov];
    [0:v][ov] overlay=10:10 [v]" -map "[v]" -map 0:a -c:v libx264
    -c:a copy -shortest Bigout.mp4


    from
    How to add my logo for the first 30 seconds in a video with ffmpeg?



    But the problem is my video's widths/heights are different and each time I add a logo, it does not cover the whole video. What should I do if I want to set the logo width/height to the width/height of the video ?



    UPDATE
    After @Behroozfar Answer, I tried to use scale2ref, with the command below:



    ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i biglogo.png -filter_complex "[1:v][0:v]scale2ref=iw/1:-1[ovrl][0v]; [0v][ovrl]overlay=0:0[v]" -map "[v] ; [1:v] fade=out:st=2:d=1:alpha=1 [ov]" -map 0:a -c:v libx264 -c:a copy -shortest Bigout.mp4



    but the question is , I can't show the logo just for one second. It exists during the whole video play.










    share|improve this question



























      0












      0








      0







      I want to show a logoon a video when the video starts. I already found this command :



      ffmpeg -i input.mp4 -framerate 30000/1001 
      -loop 1 -i test.png -filter_complex "[1:v] fade=out:st=30:d=1:alpha=1 [ov];
      [0:v][ov] overlay=10:10 [v]" -map "[v]" -map 0:a -c:v libx264
      -c:a copy -shortest Bigout.mp4


      from
      How to add my logo for the first 30 seconds in a video with ffmpeg?



      But the problem is my video's widths/heights are different and each time I add a logo, it does not cover the whole video. What should I do if I want to set the logo width/height to the width/height of the video ?



      UPDATE
      After @Behroozfar Answer, I tried to use scale2ref, with the command below:



      ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i biglogo.png -filter_complex "[1:v][0:v]scale2ref=iw/1:-1[ovrl][0v]; [0v][ovrl]overlay=0:0[v]" -map "[v] ; [1:v] fade=out:st=2:d=1:alpha=1 [ov]" -map 0:a -c:v libx264 -c:a copy -shortest Bigout.mp4



      but the question is , I can't show the logo just for one second. It exists during the whole video play.










      share|improve this question















      I want to show a logoon a video when the video starts. I already found this command :



      ffmpeg -i input.mp4 -framerate 30000/1001 
      -loop 1 -i test.png -filter_complex "[1:v] fade=out:st=30:d=1:alpha=1 [ov];
      [0:v][ov] overlay=10:10 [v]" -map "[v]" -map 0:a -c:v libx264
      -c:a copy -shortest Bigout.mp4


      from
      How to add my logo for the first 30 seconds in a video with ffmpeg?



      But the problem is my video's widths/heights are different and each time I add a logo, it does not cover the whole video. What should I do if I want to set the logo width/height to the width/height of the video ?



      UPDATE
      After @Behroozfar Answer, I tried to use scale2ref, with the command below:



      ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i biglogo.png -filter_complex "[1:v][0:v]scale2ref=iw/1:-1[ovrl][0v]; [0v][ovrl]overlay=0:0[v]" -map "[v] ; [1:v] fade=out:st=2:d=1:alpha=1 [ov]" -map 0:a -c:v libx264 -c:a copy -shortest Bigout.mp4



      but the question is , I can't show the logo just for one second. It exists during the whole video play.







      ffmpeg video-conversion






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 4 at 8:01

























      asked Oct 12 '16 at 12:51









      MHPalang

      12




      12






















          2 Answers
          2






          active

          oldest

          votes


















          2














          Use scale2ref filter



          ffmpeg -i input.mp4 -framerate 30000/1001
          -loop 1 -i test.png -filter_complex "[1:v]fade=out:st=30:d=1:alpha=1[ov];
          [ov][0:v]scale2ref[logo][video];
          [video][logo]overlay=10:10[v]" -map "[v]" -map 0:a -c:v libx264
          -c:a copy -shortest Bigout.mp4






          share|improve this answer





















          • To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different.
            – Gyan
            Oct 12 '16 at 14:21










          • @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before.
            – MHPalang
            Oct 12 '16 at 14:48



















          0














          To show the full-sized logo for one second and then a small-sized logo afterwards, use



          ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i test.png
          -filter_complex
          "[1]fade=out:st=1:d=0.9:alpha=1,trim=0:2[f];
          [1]fade=st=2:d=0.5:alpha=1,trim=0:3[s];
          [f][0]scale2ref[fs][video];[s][fs]scale2ref=iw/8:-1[ss][fo];
          [video][fo]overlay=eof_action=pass[v0];
          [v0][ss]overlay=W-w-5:H-h-5[v]"
          -map "[v]" -map 0:a -c:v libx264 -c:a copy Bigout.mp4





          share|improve this answer























          • thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video
            – MHPalang
            Oct 12 '16 at 15:48










          • sorry, [fo] in your command should have been [f].
            – MHPalang
            Oct 12 '16 at 15:50










          • Made corrections.
            – Gyan
            Oct 12 '16 at 15:55










          • Thank you. It works fine for the first part. But there is not small logo on the for the second part
            – MHPalang
            Oct 12 '16 at 16:02










          • unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish.
            – MHPalang
            Oct 12 '16 at 16:36











          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%2f1134032%2fhow-to-add-a-png-logo-to-mp4-video-with-ffmpeg-which-can-be-resize-dynamically-a%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














          Use scale2ref filter



          ffmpeg -i input.mp4 -framerate 30000/1001
          -loop 1 -i test.png -filter_complex "[1:v]fade=out:st=30:d=1:alpha=1[ov];
          [ov][0:v]scale2ref[logo][video];
          [video][logo]overlay=10:10[v]" -map "[v]" -map 0:a -c:v libx264
          -c:a copy -shortest Bigout.mp4






          share|improve this answer





















          • To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different.
            – Gyan
            Oct 12 '16 at 14:21










          • @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before.
            – MHPalang
            Oct 12 '16 at 14:48
















          2














          Use scale2ref filter



          ffmpeg -i input.mp4 -framerate 30000/1001
          -loop 1 -i test.png -filter_complex "[1:v]fade=out:st=30:d=1:alpha=1[ov];
          [ov][0:v]scale2ref[logo][video];
          [video][logo]overlay=10:10[v]" -map "[v]" -map 0:a -c:v libx264
          -c:a copy -shortest Bigout.mp4






          share|improve this answer





















          • To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different.
            – Gyan
            Oct 12 '16 at 14:21










          • @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before.
            – MHPalang
            Oct 12 '16 at 14:48














          2












          2








          2






          Use scale2ref filter



          ffmpeg -i input.mp4 -framerate 30000/1001
          -loop 1 -i test.png -filter_complex "[1:v]fade=out:st=30:d=1:alpha=1[ov];
          [ov][0:v]scale2ref[logo][video];
          [video][logo]overlay=10:10[v]" -map "[v]" -map 0:a -c:v libx264
          -c:a copy -shortest Bigout.mp4






          share|improve this answer












          Use scale2ref filter



          ffmpeg -i input.mp4 -framerate 30000/1001
          -loop 1 -i test.png -filter_complex "[1:v]fade=out:st=30:d=1:alpha=1[ov];
          [ov][0:v]scale2ref[logo][video];
          [video][logo]overlay=10:10[v]" -map "[v]" -map 0:a -c:v libx264
          -c:a copy -shortest Bigout.mp4







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 12 '16 at 13:32









          Behroozfar

          57429




          57429












          • To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different.
            – Gyan
            Oct 12 '16 at 14:21










          • @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before.
            – MHPalang
            Oct 12 '16 at 14:48


















          • To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different.
            – Gyan
            Oct 12 '16 at 14:21










          • @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before.
            – MHPalang
            Oct 12 '16 at 14:48
















          To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different.
          – Gyan
          Oct 12 '16 at 14:21




          To the OP, note that this will distort the logo if its aspect ratio and the video's aspect is different.
          – Gyan
          Oct 12 '16 at 14:21












          @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before.
          – MHPalang
          Oct 12 '16 at 14:48




          @Mulvya Actually i want to show logo for the first second of the video which cover the whole video frame, and then have the small logo for example in the left corner. I guess I should use two ffmepeg commands for this. One for adding the intro logo and then add the small logo to the video was made before.
          – MHPalang
          Oct 12 '16 at 14:48













          0














          To show the full-sized logo for one second and then a small-sized logo afterwards, use



          ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i test.png
          -filter_complex
          "[1]fade=out:st=1:d=0.9:alpha=1,trim=0:2[f];
          [1]fade=st=2:d=0.5:alpha=1,trim=0:3[s];
          [f][0]scale2ref[fs][video];[s][fs]scale2ref=iw/8:-1[ss][fo];
          [video][fo]overlay=eof_action=pass[v0];
          [v0][ss]overlay=W-w-5:H-h-5[v]"
          -map "[v]" -map 0:a -c:v libx264 -c:a copy Bigout.mp4





          share|improve this answer























          • thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video
            – MHPalang
            Oct 12 '16 at 15:48










          • sorry, [fo] in your command should have been [f].
            – MHPalang
            Oct 12 '16 at 15:50










          • Made corrections.
            – Gyan
            Oct 12 '16 at 15:55










          • Thank you. It works fine for the first part. But there is not small logo on the for the second part
            – MHPalang
            Oct 12 '16 at 16:02










          • unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish.
            – MHPalang
            Oct 12 '16 at 16:36
















          0














          To show the full-sized logo for one second and then a small-sized logo afterwards, use



          ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i test.png
          -filter_complex
          "[1]fade=out:st=1:d=0.9:alpha=1,trim=0:2[f];
          [1]fade=st=2:d=0.5:alpha=1,trim=0:3[s];
          [f][0]scale2ref[fs][video];[s][fs]scale2ref=iw/8:-1[ss][fo];
          [video][fo]overlay=eof_action=pass[v0];
          [v0][ss]overlay=W-w-5:H-h-5[v]"
          -map "[v]" -map 0:a -c:v libx264 -c:a copy Bigout.mp4





          share|improve this answer























          • thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video
            – MHPalang
            Oct 12 '16 at 15:48










          • sorry, [fo] in your command should have been [f].
            – MHPalang
            Oct 12 '16 at 15:50










          • Made corrections.
            – Gyan
            Oct 12 '16 at 15:55










          • Thank you. It works fine for the first part. But there is not small logo on the for the second part
            – MHPalang
            Oct 12 '16 at 16:02










          • unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish.
            – MHPalang
            Oct 12 '16 at 16:36














          0












          0








          0






          To show the full-sized logo for one second and then a small-sized logo afterwards, use



          ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i test.png
          -filter_complex
          "[1]fade=out:st=1:d=0.9:alpha=1,trim=0:2[f];
          [1]fade=st=2:d=0.5:alpha=1,trim=0:3[s];
          [f][0]scale2ref[fs][video];[s][fs]scale2ref=iw/8:-1[ss][fo];
          [video][fo]overlay=eof_action=pass[v0];
          [v0][ss]overlay=W-w-5:H-h-5[v]"
          -map "[v]" -map 0:a -c:v libx264 -c:a copy Bigout.mp4





          share|improve this answer














          To show the full-sized logo for one second and then a small-sized logo afterwards, use



          ffmpeg -i input.mp4 -framerate 30000/1001 -loop 1 -i test.png
          -filter_complex
          "[1]fade=out:st=1:d=0.9:alpha=1,trim=0:2[f];
          [1]fade=st=2:d=0.5:alpha=1,trim=0:3[s];
          [f][0]scale2ref[fs][video];[s][fs]scale2ref=iw/8:-1[ss][fo];
          [video][fo]overlay=eof_action=pass[v0];
          [v0][ss]overlay=W-w-5:H-h-5[v]"
          -map "[v]" -map 0:a -c:v libx264 -c:a copy Bigout.mp4






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 12 '16 at 17:35

























          answered Oct 12 '16 at 15:12









          Gyan

          14.4k21644




          14.4k21644












          • thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video
            – MHPalang
            Oct 12 '16 at 15:48










          • sorry, [fo] in your command should have been [f].
            – MHPalang
            Oct 12 '16 at 15:50










          • Made corrections.
            – Gyan
            Oct 12 '16 at 15:55










          • Thank you. It works fine for the first part. But there is not small logo on the for the second part
            – MHPalang
            Oct 12 '16 at 16:02










          • unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish.
            – MHPalang
            Oct 12 '16 at 16:36


















          • thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video
            – MHPalang
            Oct 12 '16 at 15:48










          • sorry, [fo] in your command should have been [f].
            – MHPalang
            Oct 12 '16 at 15:50










          • Made corrections.
            – Gyan
            Oct 12 '16 at 15:55










          • Thank you. It works fine for the first part. But there is not small logo on the for the second part
            – MHPalang
            Oct 12 '16 at 16:02










          • unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish.
            – MHPalang
            Oct 12 '16 at 16:36
















          thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video
          – MHPalang
          Oct 12 '16 at 15:48




          thank you man. I run the command and it said there no f! it seems [of] in your command should have been [f]. and run it again and I dont see any logo in my video. It seems nothing happened to the video
          – MHPalang
          Oct 12 '16 at 15:48












          sorry, [fo] in your command should have been [f].
          – MHPalang
          Oct 12 '16 at 15:50




          sorry, [fo] in your command should have been [f].
          – MHPalang
          Oct 12 '16 at 15:50












          Made corrections.
          – Gyan
          Oct 12 '16 at 15:55




          Made corrections.
          – Gyan
          Oct 12 '16 at 15:55












          Thank you. It works fine for the first part. But there is not small logo on the for the second part
          – MHPalang
          Oct 12 '16 at 16:02




          Thank you. It works fine for the first part. But there is not small logo on the for the second part
          – MHPalang
          Oct 12 '16 at 16:02












          unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish.
          – MHPalang
          Oct 12 '16 at 16:36




          unfortunately your command doesn't work for the second part... and make the video stop at the last two seconds before finish. By the way it may seems a little bit stupid, but I decided to run two commands. first put the intro logo at the beginning and then add the small logo. But when I run your command for the first part, video stops two seconds before finish.
          – MHPalang
          Oct 12 '16 at 16:36


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f1134032%2fhow-to-add-a-png-logo-to-mp4-video-with-ffmpeg-which-can-be-resize-dynamically-a%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

          Сан-Квентин

          Алькесар

          Josef Freinademetz