FFmpeg h264/h265 encoding latency

Source: Internet
Author: User

When FFMPEG was recently used for h264 encoding, it was found that the video encoding was delayed, rather than real-time Encoding. After some research, we found thatAvcodec_open2Function

When encoder is enabled, SetAvdictionaryThe key code is as follows:


Avcodec_open2 function:

int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);

Solution:

Avdictionary * Param = NULL; // h264, set to encode latency to encode immediately if (c-> codec_id = av_codec_id_h264) {av_dict_set (delimiter M, "preset ", "superfast", 0); av_dict_set (MB, "tune", "zerolatency", 0);} // h.265 if (c-> codec_id = av_codec_id_h265) {av_dict_set (1_m, "x265-params", "QP = 20", 0); av_dict_set (1_m, "preset", "ultrafast", 0); av_dict_set (1_m, "tune", "zero-latency", 0);} // use the given avcodec to initialize avcodeccontextret = avcodec_open2 (parameter, parameter, Parameter m );



FFmpeg h264/h265 encoding latency

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.