FFmpeg: Masking webcam while recording












0














I hope you're all having a great day.



I'm trying to record a webcam that is shaped as a rounded-rectangular on the top-right of the screen.



I'm using this mask



The shape of the webcam in the video is actually the same as the mask but the problem is that it can only record the first frame then the webcam freezes until the end of the video.



ffmpeg -f gdigrab -s 1360x768 -framerate 30 -i desktop 
-f dshow -i video="webcam-device":audio="audio-input-device"
-filter_complex "movie='roundedrectangle.png',alphaextract[a];[1:v][a]alphamerge,scale=256:-1[cutout];[0:v][cutout]overlay=10:10,split=2[output0][output1]"
-map 1:a -c:a aac -map "[output0]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output0.mp4
-map 1:a -c:a aac -map "[output1]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output1.mp4


Expected output: Two videos with sound that got a rounded-rectangular webcam on the top left of the screen.



Thank you so much.










share|improve this question



























    0














    I hope you're all having a great day.



    I'm trying to record a webcam that is shaped as a rounded-rectangular on the top-right of the screen.



    I'm using this mask



    The shape of the webcam in the video is actually the same as the mask but the problem is that it can only record the first frame then the webcam freezes until the end of the video.



    ffmpeg -f gdigrab -s 1360x768 -framerate 30 -i desktop 
    -f dshow -i video="webcam-device":audio="audio-input-device"
    -filter_complex "movie='roundedrectangle.png',alphaextract[a];[1:v][a]alphamerge,scale=256:-1[cutout];[0:v][cutout]overlay=10:10,split=2[output0][output1]"
    -map 1:a -c:a aac -map "[output0]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output0.mp4
    -map 1:a -c:a aac -map "[output1]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output1.mp4


    Expected output: Two videos with sound that got a rounded-rectangular webcam on the top left of the screen.



    Thank you so much.










    share|improve this question

























      0












      0








      0







      I hope you're all having a great day.



      I'm trying to record a webcam that is shaped as a rounded-rectangular on the top-right of the screen.



      I'm using this mask



      The shape of the webcam in the video is actually the same as the mask but the problem is that it can only record the first frame then the webcam freezes until the end of the video.



      ffmpeg -f gdigrab -s 1360x768 -framerate 30 -i desktop 
      -f dshow -i video="webcam-device":audio="audio-input-device"
      -filter_complex "movie='roundedrectangle.png',alphaextract[a];[1:v][a]alphamerge,scale=256:-1[cutout];[0:v][cutout]overlay=10:10,split=2[output0][output1]"
      -map 1:a -c:a aac -map "[output0]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output0.mp4
      -map 1:a -c:a aac -map "[output1]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output1.mp4


      Expected output: Two videos with sound that got a rounded-rectangular webcam on the top left of the screen.



      Thank you so much.










      share|improve this question













      I hope you're all having a great day.



      I'm trying to record a webcam that is shaped as a rounded-rectangular on the top-right of the screen.



      I'm using this mask



      The shape of the webcam in the video is actually the same as the mask but the problem is that it can only record the first frame then the webcam freezes until the end of the video.



      ffmpeg -f gdigrab -s 1360x768 -framerate 30 -i desktop 
      -f dshow -i video="webcam-device":audio="audio-input-device"
      -filter_complex "movie='roundedrectangle.png',alphaextract[a];[1:v][a]alphamerge,scale=256:-1[cutout];[0:v][cutout]overlay=10:10,split=2[output0][output1]"
      -map 1:a -c:a aac -map "[output0]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output0.mp4
      -map 1:a -c:a aac -map "[output1]" -c:v libx264 -b:v 2M -preset fast -s 1280x720 -f mp4 output1.mp4


      Expected output: Two videos with sound that got a rounded-rectangular webcam on the top left of the screen.



      Thank you so much.







      ffmpeg mask






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 11 '18 at 15:18









      Sano

      73




      73






















          1 Answer
          1






          active

          oldest

          votes


















          0














          alphamerge terminates with the shortest input and your 2nd input is a single frame. So you need to loop it.



          movie='roundedrectangle.png':loop=0,alphaextract[a];





          share|improve this answer





















          • Good lord this is the third time you help me out, I'm feeling embarrassed :') Thank you so much
            – Sano
            Dec 12 '18 at 9:01











          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%2f1382664%2fffmpeg-masking-webcam-while-recording%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














          alphamerge terminates with the shortest input and your 2nd input is a single frame. So you need to loop it.



          movie='roundedrectangle.png':loop=0,alphaextract[a];





          share|improve this answer





















          • Good lord this is the third time you help me out, I'm feeling embarrassed :') Thank you so much
            – Sano
            Dec 12 '18 at 9:01
















          0














          alphamerge terminates with the shortest input and your 2nd input is a single frame. So you need to loop it.



          movie='roundedrectangle.png':loop=0,alphaextract[a];





          share|improve this answer





















          • Good lord this is the third time you help me out, I'm feeling embarrassed :') Thank you so much
            – Sano
            Dec 12 '18 at 9:01














          0












          0








          0






          alphamerge terminates with the shortest input and your 2nd input is a single frame. So you need to loop it.



          movie='roundedrectangle.png':loop=0,alphaextract[a];





          share|improve this answer












          alphamerge terminates with the shortest input and your 2nd input is a single frame. So you need to loop it.



          movie='roundedrectangle.png':loop=0,alphaextract[a];






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 11 '18 at 17:05









          Gyan

          14.5k21745




          14.5k21745












          • Good lord this is the third time you help me out, I'm feeling embarrassed :') Thank you so much
            – Sano
            Dec 12 '18 at 9:01


















          • Good lord this is the third time you help me out, I'm feeling embarrassed :') Thank you so much
            – Sano
            Dec 12 '18 at 9:01
















          Good lord this is the third time you help me out, I'm feeling embarrassed :') Thank you so much
          – Sano
          Dec 12 '18 at 9:01




          Good lord this is the third time you help me out, I'm feeling embarrassed :') Thank you so much
          – Sano
          Dec 12 '18 at 9:01


















          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%2f1382664%2fffmpeg-masking-webcam-while-recording%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

          Plaza Victoria

          Puebla de Zaragoza

          Musa