songqi
songqi

Reputation: 31

How to set x264 encode parameters through ffmpeg AVCodecContext

I'm trying to use ffmpeg/libx264 to encode and transmit a real-time video, when I use av_dict_set(&opts, "tune", "zerolatency", 0); the system works well. As the X264 encode parameters are set by ffmpeg using av_dict_set, for some research purpose I want to change them by myself. But some parameters in x264_param_t can not correspond to those parameters in AVCodecContext, such as vfr_input. So I want to know if there is a directly way to transmit parameters into X264 encoder when using libx264 in ffmpeg.


Can anyone help me? Thanks

Upvotes: 3

Views: 5867

Answers (1)

kshahar
kshahar

Reputation: 10513

Try calling av_opt_set with the codec context priv_data structure:

AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);
AVCodecContext *codecContex = avcodec_alloc_context3(codec);
av_opt_set(codecContex->priv_data, "preset", "ultrafast", 0);
av_opt_set(codecContex->priv_data, "tune", "zerolatency", 0);

Error checking omitted for brevity.

Upvotes: 4

Related Questions