Search code examples
videoffmpegdecodinglibx264

Tune FFmpeg H.264 Decoder


I'm using the FFmpeg avcodec to decode live video - the avcodec_decode_video2 function from libx264 to be exact. How can I decrease the decoding time for each frame? At the moment it takes 20 ms for each frame (frame size about 1.5 KB).


Solution

  • Ok, may be it will be helpful for someone. By the way, for decoding we use function

    avcodec_video_decode2
    from FFMPEG. And we can make delay lesser by two ways. The first: turn on
    AVCodecContext *ctx->thread_count=N
    But in this case we get a stream with a delay however it is not good for real time video. The second way is use coder which will be code image in slice based mode e.g. libx264. In this case the delay is absent by definition. But it makes some limitation e.g. a count of threads is a count of slice.