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!
Yes. Here is ffmpeg's official examples: https://github.com/FFmpeg/FFmpeg/tree/master/doc/examples
Always use yuv formats like yuv420p. Do not use RGB, even if it is supported will be inefficient.
Yes, 2 pass gives advantages but not necessary.
What you need is
sws_scale
functionality of ffmpeg. This does two things, scaling and format conversion, both can be performed same time. Checkscaling_video.c
example.