Add image with scale + rotation to video overlay with FFMPEG?












0















I want to add overlay images to videos with params



1: w:h --> is width and height of image on the video



2: r --> Radian is rotation of images



3: center (x,y) --> is center point of image in the video



This is my FFMPEG command :




-i video.mp4 -i image.png filter_complex [1:v]scale=w:h[scale];[scale]rotate=r:ow=iw:oh=ih[rotate];[0:v][rotate]overlay=x-(w/2):y-(h/2)




But the result not correct. It's Only work with scale=1 and rotate=0 radian



How can i do this ?










share|improve this question



























    0















    I want to add overlay images to videos with params



    1: w:h --> is width and height of image on the video



    2: r --> Radian is rotation of images



    3: center (x,y) --> is center point of image in the video



    This is my FFMPEG command :




    -i video.mp4 -i image.png filter_complex [1:v]scale=w:h[scale];[scale]rotate=r:ow=iw:oh=ih[rotate];[0:v][rotate]overlay=x-(w/2):y-(h/2)




    But the result not correct. It's Only work with scale=1 and rotate=0 radian



    How can i do this ?










    share|improve this question

























      0












      0








      0








      I want to add overlay images to videos with params



      1: w:h --> is width and height of image on the video



      2: r --> Radian is rotation of images



      3: center (x,y) --> is center point of image in the video



      This is my FFMPEG command :




      -i video.mp4 -i image.png filter_complex [1:v]scale=w:h[scale];[scale]rotate=r:ow=iw:oh=ih[rotate];[0:v][rotate]overlay=x-(w/2):y-(h/2)




      But the result not correct. It's Only work with scale=1 and rotate=0 radian



      How can i do this ?










      share|improve this question














      I want to add overlay images to videos with params



      1: w:h --> is width and height of image on the video



      2: r --> Radian is rotation of images



      3: center (x,y) --> is center point of image in the video



      This is my FFMPEG command :




      -i video.mp4 -i image.png filter_complex [1:v]scale=w:h[scale];[scale]rotate=r:ow=iw:oh=ih[rotate];[0:v][rotate]overlay=x-(w/2):y-(h/2)




      But the result not correct. It's Only work with scale=1 and rotate=0 radian



      How can i do this ?







      image video ffmpeg rotation overlay






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 10:24









      Young KingYoung King

      308




      308
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Use



          [1:v]scale=w:h,pad=iw+4:ih+4:black@0[scale];[scale]rotate=r:ow='rotw(r)':oh='roth(r)'[rotate]


          A bit of transparent padding is added to the image before rotation. This is because the rotate filter will fill the gaps in the canvas with the input's border pixel color. Also, the output size has to be adjusted to accommodate the whole image after rotation. See the docs for the rotate filter.






          share|improve this answer
























          • Thankyou so @Gyan

            – Young King
            Nov 20 '18 at 4:02












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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%2fstackoverflow.com%2fquestions%2f53335880%2fadd-image-with-scale-rotation-to-video-overlay-with-ffmpeg%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









          0














          Use



          [1:v]scale=w:h,pad=iw+4:ih+4:black@0[scale];[scale]rotate=r:ow='rotw(r)':oh='roth(r)'[rotate]


          A bit of transparent padding is added to the image before rotation. This is because the rotate filter will fill the gaps in the canvas with the input's border pixel color. Also, the output size has to be adjusted to accommodate the whole image after rotation. See the docs for the rotate filter.






          share|improve this answer
























          • Thankyou so @Gyan

            – Young King
            Nov 20 '18 at 4:02
















          0














          Use



          [1:v]scale=w:h,pad=iw+4:ih+4:black@0[scale];[scale]rotate=r:ow='rotw(r)':oh='roth(r)'[rotate]


          A bit of transparent padding is added to the image before rotation. This is because the rotate filter will fill the gaps in the canvas with the input's border pixel color. Also, the output size has to be adjusted to accommodate the whole image after rotation. See the docs for the rotate filter.






          share|improve this answer
























          • Thankyou so @Gyan

            – Young King
            Nov 20 '18 at 4:02














          0












          0








          0







          Use



          [1:v]scale=w:h,pad=iw+4:ih+4:black@0[scale];[scale]rotate=r:ow='rotw(r)':oh='roth(r)'[rotate]


          A bit of transparent padding is added to the image before rotation. This is because the rotate filter will fill the gaps in the canvas with the input's border pixel color. Also, the output size has to be adjusted to accommodate the whole image after rotation. See the docs for the rotate filter.






          share|improve this answer













          Use



          [1:v]scale=w:h,pad=iw+4:ih+4:black@0[scale];[scale]rotate=r:ow='rotw(r)':oh='roth(r)'[rotate]


          A bit of transparent padding is added to the image before rotation. This is because the rotate filter will fill the gaps in the canvas with the input's border pixel color. Also, the output size has to be adjusted to accommodate the whole image after rotation. See the docs for the rotate filter.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 13:25









          GyanGyan

          34.1k22971




          34.1k22971













          • Thankyou so @Gyan

            – Young King
            Nov 20 '18 at 4:02



















          • Thankyou so @Gyan

            – Young King
            Nov 20 '18 at 4:02

















          Thankyou so @Gyan

          – Young King
          Nov 20 '18 at 4:02





          Thankyou so @Gyan

          – Young King
          Nov 20 '18 at 4:02




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53335880%2fadd-image-with-scale-rotation-to-video-overlay-with-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

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python