简体   繁体   中英

How to set x264 encode parameters through ffmpeg AVCodecContext

I'm trying to use ffmpeg/libx264 to encode and transmit a realtime 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM