Question

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?

Was it helpful?

Solution

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 );

OTHER TIPS

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top