encode YUV420 frame to VP9











up vote
1
down vote

favorite












As title,



I'm pulling frames from a IP camera. I converted the input raw data to YUV420 format, and would like to encode YUV420 to VP9, and save frames as .webm format. Would I be able to do that? Or should I input a BGR444 format for encoding?



BTW, to set up the parameters for encoding vp9. Is the av_dict_set() the right function for setting parameters?



Ex: (http://wiki.webmproject.org/ffmpeg/vp9-encoding-guide)



av_dict_set(&opt, "crf"    , "23", 0);
av_dict_set(&opt, "speed" , "4" , 0);
av_dict_set(&opt, "threads", "8" , 0);
av_dict_set(&opt, "pass" , "1" , 0);
av_dict_set(&opt, "b:v", "1400k", 0);


Edit: The wiki uses 2 pass for setting parameters, would I be able to do in with 1 pass?



Edit2: Blow code seems to be working, wonder how can I bring the size of the videos (vp9) down? Currently, I have similar size as using h264 encoder.



    av_dict_set(&opt, "crf"    ,        "45", 0);  
av_dict_set(&opt, "speed" , "8" , 0);
av_dict_set(&opt, "quality", "realtime", 0);
av_dict_set(&opt, "threads", "8" , 0);
av_dict_set(&opt, "tile-columns", "3", 0);
av_dict_set(&opt, "frame-parallel", "1", 0);
av_dict_set(&opt, "row-mt", "1", 0);


Update1:
YUV420P can be encoded as VP9!










share|improve this question




























    up vote
    1
    down vote

    favorite












    As title,



    I'm pulling frames from a IP camera. I converted the input raw data to YUV420 format, and would like to encode YUV420 to VP9, and save frames as .webm format. Would I be able to do that? Or should I input a BGR444 format for encoding?



    BTW, to set up the parameters for encoding vp9. Is the av_dict_set() the right function for setting parameters?



    Ex: (http://wiki.webmproject.org/ffmpeg/vp9-encoding-guide)



    av_dict_set(&opt, "crf"    , "23", 0);
    av_dict_set(&opt, "speed" , "4" , 0);
    av_dict_set(&opt, "threads", "8" , 0);
    av_dict_set(&opt, "pass" , "1" , 0);
    av_dict_set(&opt, "b:v", "1400k", 0);


    Edit: The wiki uses 2 pass for setting parameters, would I be able to do in with 1 pass?



    Edit2: Blow code seems to be working, wonder how can I bring the size of the videos (vp9) down? Currently, I have similar size as using h264 encoder.



        av_dict_set(&opt, "crf"    ,        "45", 0);  
    av_dict_set(&opt, "speed" , "8" , 0);
    av_dict_set(&opt, "quality", "realtime", 0);
    av_dict_set(&opt, "threads", "8" , 0);
    av_dict_set(&opt, "tile-columns", "3", 0);
    av_dict_set(&opt, "frame-parallel", "1", 0);
    av_dict_set(&opt, "row-mt", "1", 0);


    Update1:
    YUV420P can be encoded as VP9!










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      As title,



      I'm pulling frames from a IP camera. I converted the input raw data to YUV420 format, and would like to encode YUV420 to VP9, and save frames as .webm format. Would I be able to do that? Or should I input a BGR444 format for encoding?



      BTW, to set up the parameters for encoding vp9. Is the av_dict_set() the right function for setting parameters?



      Ex: (http://wiki.webmproject.org/ffmpeg/vp9-encoding-guide)



      av_dict_set(&opt, "crf"    , "23", 0);
      av_dict_set(&opt, "speed" , "4" , 0);
      av_dict_set(&opt, "threads", "8" , 0);
      av_dict_set(&opt, "pass" , "1" , 0);
      av_dict_set(&opt, "b:v", "1400k", 0);


      Edit: The wiki uses 2 pass for setting parameters, would I be able to do in with 1 pass?



      Edit2: Blow code seems to be working, wonder how can I bring the size of the videos (vp9) down? Currently, I have similar size as using h264 encoder.



          av_dict_set(&opt, "crf"    ,        "45", 0);  
      av_dict_set(&opt, "speed" , "8" , 0);
      av_dict_set(&opt, "quality", "realtime", 0);
      av_dict_set(&opt, "threads", "8" , 0);
      av_dict_set(&opt, "tile-columns", "3", 0);
      av_dict_set(&opt, "frame-parallel", "1", 0);
      av_dict_set(&opt, "row-mt", "1", 0);


      Update1:
      YUV420P can be encoded as VP9!










      share|improve this question















      As title,



      I'm pulling frames from a IP camera. I converted the input raw data to YUV420 format, and would like to encode YUV420 to VP9, and save frames as .webm format. Would I be able to do that? Or should I input a BGR444 format for encoding?



      BTW, to set up the parameters for encoding vp9. Is the av_dict_set() the right function for setting parameters?



      Ex: (http://wiki.webmproject.org/ffmpeg/vp9-encoding-guide)



      av_dict_set(&opt, "crf"    , "23", 0);
      av_dict_set(&opt, "speed" , "4" , 0);
      av_dict_set(&opt, "threads", "8" , 0);
      av_dict_set(&opt, "pass" , "1" , 0);
      av_dict_set(&opt, "b:v", "1400k", 0);


      Edit: The wiki uses 2 pass for setting parameters, would I be able to do in with 1 pass?



      Edit2: Blow code seems to be working, wonder how can I bring the size of the videos (vp9) down? Currently, I have similar size as using h264 encoder.



          av_dict_set(&opt, "crf"    ,        "45", 0);  
      av_dict_set(&opt, "speed" , "8" , 0);
      av_dict_set(&opt, "quality", "realtime", 0);
      av_dict_set(&opt, "threads", "8" , 0);
      av_dict_set(&opt, "tile-columns", "3", 0);
      av_dict_set(&opt, "frame-parallel", "1", 0);
      av_dict_set(&opt, "row-mt", "1", 0);


      Update1:
      YUV420P can be encoded as VP9!







      video encoding ffmpeg webm vp9






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 at 23:09

























      asked Nov 19 at 20:07









      User800222

      295




      295
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote














          I'm pulling frames from a IP camera. I converted the input raw data to
          YUV420 format, and would like to encode YUV420 to VP9, and save frames
          as .webm format. Would I be able to do that?




          Yes. Here is ffmpeg's official examples: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples




          Or should I input a BGR444 format for encoding?




          Always use yuv formats like yuv420p. Do not use RGB, even if it is supported will be inefficient.




          The wiki uses 2 pass for setting parameters, would I be able to do in
          with 1 pass




          Yes, 2 pass gives advantages but not necessary.




          Blow code seems to be working, wonder how can I bring the size of the
          videos (vp9) down? Currently, I have similar size as using h264
          encoder.




          What you need is sws_scale functionality of ffmpeg. This does two things, scaling and format conversion, both can be performed same time. Check scaling_video.c example.






          share|improve this answer





















          • I have a downscaled frame already for both h264 and vp9 to encode and would like to get the advantage of VP9's which having a smaller size but maintain similar quality as h264. The video is fairly short, I manage to change the parameter of keyframe intervals to get the vp9's file size down.
            – User800222
            Nov 21 at 8:50











          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',
          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%2f53381888%2fencode-yuv420-frame-to-vp9%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








          up vote
          0
          down vote














          I'm pulling frames from a IP camera. I converted the input raw data to
          YUV420 format, and would like to encode YUV420 to VP9, and save frames
          as .webm format. Would I be able to do that?




          Yes. Here is ffmpeg's official examples: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples




          Or should I input a BGR444 format for encoding?




          Always use yuv formats like yuv420p. Do not use RGB, even if it is supported will be inefficient.




          The wiki uses 2 pass for setting parameters, would I be able to do in
          with 1 pass




          Yes, 2 pass gives advantages but not necessary.




          Blow code seems to be working, wonder how can I bring the size of the
          videos (vp9) down? Currently, I have similar size as using h264
          encoder.




          What you need is sws_scale functionality of ffmpeg. This does two things, scaling and format conversion, both can be performed same time. Check scaling_video.c example.






          share|improve this answer





















          • I have a downscaled frame already for both h264 and vp9 to encode and would like to get the advantage of VP9's which having a smaller size but maintain similar quality as h264. The video is fairly short, I manage to change the parameter of keyframe intervals to get the vp9's file size down.
            – User800222
            Nov 21 at 8:50















          up vote
          0
          down vote














          I'm pulling frames from a IP camera. I converted the input raw data to
          YUV420 format, and would like to encode YUV420 to VP9, and save frames
          as .webm format. Would I be able to do that?




          Yes. Here is ffmpeg's official examples: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples




          Or should I input a BGR444 format for encoding?




          Always use yuv formats like yuv420p. Do not use RGB, even if it is supported will be inefficient.




          The wiki uses 2 pass for setting parameters, would I be able to do in
          with 1 pass




          Yes, 2 pass gives advantages but not necessary.




          Blow code seems to be working, wonder how can I bring the size of the
          videos (vp9) down? Currently, I have similar size as using h264
          encoder.




          What you need is sws_scale functionality of ffmpeg. This does two things, scaling and format conversion, both can be performed same time. Check scaling_video.c example.






          share|improve this answer





















          • I have a downscaled frame already for both h264 and vp9 to encode and would like to get the advantage of VP9's which having a smaller size but maintain similar quality as h264. The video is fairly short, I manage to change the parameter of keyframe intervals to get the vp9's file size down.
            – User800222
            Nov 21 at 8:50













          up vote
          0
          down vote










          up vote
          0
          down vote










          I'm pulling frames from a IP camera. I converted the input raw data to
          YUV420 format, and would like to encode YUV420 to VP9, and save frames
          as .webm format. Would I be able to do that?




          Yes. Here is ffmpeg's official examples: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples




          Or should I input a BGR444 format for encoding?




          Always use yuv formats like yuv420p. Do not use RGB, even if it is supported will be inefficient.




          The wiki uses 2 pass for setting parameters, would I be able to do in
          with 1 pass




          Yes, 2 pass gives advantages but not necessary.




          Blow code seems to be working, wonder how can I bring the size of the
          videos (vp9) down? Currently, I have similar size as using h264
          encoder.




          What you need is sws_scale functionality of ffmpeg. This does two things, scaling and format conversion, both can be performed same time. Check scaling_video.c example.






          share|improve this answer













          I'm pulling frames from a IP camera. I converted the input raw data to
          YUV420 format, and would like to encode YUV420 to VP9, and save frames
          as .webm format. Would I be able to do that?




          Yes. Here is ffmpeg's official examples: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples




          Or should I input a BGR444 format for encoding?




          Always use yuv formats like yuv420p. Do not use RGB, even if it is supported will be inefficient.




          The wiki uses 2 pass for setting parameters, would I be able to do in
          with 1 pass




          Yes, 2 pass gives advantages but not necessary.




          Blow code seems to be working, wonder how can I bring the size of the
          videos (vp9) down? Currently, I have similar size as using h264
          encoder.




          What you need is sws_scale functionality of ffmpeg. This does two things, scaling and format conversion, both can be performed same time. Check scaling_video.c example.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 at 7:27









          the kamilz

          7021411




          7021411












          • I have a downscaled frame already for both h264 and vp9 to encode and would like to get the advantage of VP9's which having a smaller size but maintain similar quality as h264. The video is fairly short, I manage to change the parameter of keyframe intervals to get the vp9's file size down.
            – User800222
            Nov 21 at 8:50


















          • I have a downscaled frame already for both h264 and vp9 to encode and would like to get the advantage of VP9's which having a smaller size but maintain similar quality as h264. The video is fairly short, I manage to change the parameter of keyframe intervals to get the vp9's file size down.
            – User800222
            Nov 21 at 8:50
















          I have a downscaled frame already for both h264 and vp9 to encode and would like to get the advantage of VP9's which having a smaller size but maintain similar quality as h264. The video is fairly short, I manage to change the parameter of keyframe intervals to get the vp9's file size down.
          – User800222
          Nov 21 at 8:50




          I have a downscaled frame already for both h264 and vp9 to encode and would like to get the advantage of VP9's which having a smaller size but maintain similar quality as h264. The video is fairly short, I manage to change the parameter of keyframe intervals to get the vp9's file size down.
          – User800222
          Nov 21 at 8:50


















          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.





          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%2fstackoverflow.com%2fquestions%2f53381888%2fencode-yuv420-frame-to-vp9%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

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          TypeError: fit_transform() missing 1 required positional argument: 'X'