I'm using libx264 via ffmpeg (in a C++ program), and I need to know how to activate the "veryfast" preset. A grep in the x264 source tree yields:
include/x264.h:static const char * const x264_preset_names[] = { "ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo", 0 };
Which inclines me to believe that x264 itself supports this preset as opposed to just being implemented in ffmpeg as a collection of other settings. So, the question is: How do I get ffmpeg to activate the x264 "veryfast" preset?
You gotta create a dictionary and then use this dictionary with all the parameters you need when opening the codec!
AVDictionary * codec_options( 0 );
av_dict_set( &codec_options, "preset", "veryfast", 0 );
// av_dict_set( &codec_options, "AnyCodecParameter", "Value", 0 );
avcodec_open2( codecContext, videoCodec, &codec_options );
libavutil defines av_opt_set().... All you have to do is include "libavutil/opt.h" and then:
av_opt_set(codecContext->priv_data, "preset", "veryfast", 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With