I am using the libraries to decode a video stream on an embedded processor. The stream is an SDP/RTP H.264 stream. The decoder is working fine. The problem is that because the processor is somewhat limited it can not keep up with the video in real time, and gradually falls behind. I am wondering if there is any way to force the avcodec library to drop frames in order to keep up, instead of saving lots of frames in a buffer and gradually falling behind realtime?

I would like to force the library to decode the most recent available frame, instead of the oldest frame so that the video has the least latency that my slow processor can provide.

My main read function is essentially just this:

goodRead = av_read_frame(Cvt->pFormatCtx, &packet);
    if(goodRead < 0) return goodRead;
        // Is this a packet from the video stream?
        if(packet.stream_index==Cvt->videoStream)
        {
            // Decode video frame
avcodec_decode_video(Cvt->pCodecCtx, Cvt->pFrame, &frameFinished, packet.data, packet.size); int ret = sws_scale(Cvt->img_convert_ctx, Cvt->pFrame->data, Cvt- >pFrame->linesize, 0, Cvt->pCodecCtx->height, Cvt->pFrameYUV->data, Cvt->pFrameYUV- >linesize);
        }

Any suggestions would be appreciated. For example is there any way to force it to attempt to do real time decoding? Or to flush out the buffer after each read so that the next decode would get the next frame that came in?


Thanks,


--Adam



_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to