Hi All,

(please forgive me for top-posting, but I'm a programmer not a social
site frequenter ;-) )

As was mentioned you cannot pick out p-frames and throw them away. So if
your CPU is overloaded, one choice is to
Display only the i-frames, which are complete for MPEG-4 and complete
for baseline and mainline H.264. Once you throw
B-frames into the picture, this technique may not work.


This code works for me to decode i-frame only for MPEG-4 and H.264 (IP
frame) style video:

        if (bIFrameOnly) // only want to show complete i-frames
                _pCtx->pCodecCtx->skip_frame = AVDISCARD_NONKEY;
        else
                _pCtx->pCodecCtx->skip_frame = AVDISCARD_DEFAULT;



The code also works for H.264 in the decoder, but the gotPicture return
vaues are wrong, so to see if you want to render the frame you have to:

                int ret = avcodec_decode_video( _pCtx->pCodecCtx,
                        _pCtx->pFrame,
                        &gotPicture,
                        (unsigned char*)pFrameBuffer,
                        length);

                // failed to decode this frame // WORKS ONLY FOR MPEG-4
                if (gotPicture == 0 || ret <= 0)
                        return -1;

                // For H.264 iframe only mode, gotPicture value is not
being set correctly by avcodec_decode_video function 
                // so if we are in iframe only mode and the output frame
is not a key frame then return -3
                // NOTE - This is behavior is for H.264 only and not
MPEG4
                //
                if(_pCtx->bIFrameOnly && _pCtx->pFrame->key_frame != 1)
                        return -3;

Best Of Luck,

Rusty





-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Adam Dershowitz,
Ph.D., P.E.
Sent: Friday, August 14, 2009 4:24 PM
To: Libav* user questions and discussions
Subject: Re: [libav-user] Decode latency


On Aug 14, 2009, at 12:11 PM, Chris wrote:

> 2009/8/13 Adam Dershowitz <[email protected]>:
>> 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?
>
> I'm not fully qualified to answer but I'll have a go at making a 
> couple of suggestions!
>
> Firstly you need to be careful because you can't throw away random 
> p-frames because each p-frame could refer to the next one (or more 
> than one I think). If you show a p-frame, then miss one, then display 
> the next one, you'll get errors from ffmpeg and the video will almost 
> certainly distort  You can only throw frames away if you are prepared 
> to wait until the next IDR frame comes since an IDR frame is a full 
> picture (again *I think!*) and it doesn't refer to any other frames.

Thanks for the information.
I am hoping that there is some way that the decoder might be able to
help out some.  I have been looking at the ffmpeg code, and specifically
looking at the -re option.  But, it seem that it is only able to slow
things down, by sleeping between frames.  That option doesn't speed
things up by throwing away, or at least not fully decoding, images or
frames.

It seems like I should be able to just decode enough to figure out the
next image and go to that, without spending all those cycles decoding an
image that is already minutes behind "real time".

Again,

thanks,

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

- ------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this transmission is 
legally privileged and confidential, intended only for the use of the 
individual(s) or entities named above. This email and any files transmitted 
with it are the property of Pelco. If the reader of this message is not the 
intended recipient, or an employee or agent responsible for delivering this 
message to the intended recipient, you are hereby notified that any review, 
disclosure, copying, distribution, retention, or any action taken or omitted to 
be taken in reliance on it is prohibited and may be unlawful. If you receive 
this communication in error, please notify us immediately by telephone call to 
+1-559-292-1981 or forward the e-mail to [email protected] and then 
permanently delete the e-mail and destroy all soft and hard copies of the 
message and any attachments. Thank you for your cooperation. 
- ------------------------------------------------------------------------------
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to