简体   繁体   English

如何通过ffmpeg AVCodecContext设置x264编码参数

[英]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); 当我使用** av_dict_set(&opts,“tune”,“zerolatency”,0)时,我正在尝试使用ffmpeg / libx264来编码和传输实时视频; ** 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. 由于x264编码参数是由ffmpeg使用av_dict_set设置的,出于某些研究目的,我想自己更改它们。 But some parameters in x264_param_t can not correspond to those parameters in AVCodecContext , such as vfr_input . 但在某些x264_param_t参数可以不对应于那些AVCodecContext参数,如vfr_input。 So I want to know if there is a directly way to transmit parameters into X264 encoder when using libx264 in ffmpeg. 所以我想知道在ffmpeg中使用libx264时是否有直接的方法将参数传输到X264编码器。


Can anyone help me? 谁能帮我? Thanks 谢谢

Try calling av_opt_set with the codec context priv_data structure: 尝试调用av_opt_set与编解码器的情况下priv_data结构:

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. 为简洁起见,省略了错误检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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