3

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!

User800222
  • 351
  • 4
  • 16

1 Answers1

0

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.

the kamilz
  • 1,860
  • 1
  • 15
  • 19
  • 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 '18 at 08:50