[Libav-user] avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet) why most of the time frameFinished is zero ?

sithruk sana get2jils at gmail.com
Tue May 27 18:21:44 CEST 2014


Thanks for the information.  Kindly correct me if my understand is right ?

1)  Packet can be of any type 'I', 'P', or 'B'   that we receive from
av_read_frame.   // that ie compressed packet.

        'I" frame represents the compete frame.
        'P" frame represents the delta. it requires either previous 'I' or
'P' frame.
        'B' frame depends  closest preceeding or following 'I' or 'P' frame

     So, av_read_frame ( context, packet)
                    - Allocates the internal memory and keeps the
compressed packet.


*     NOTE: We should not free [  av_free_packet (packet) ] if we are using
shallow copy of 'packet' . For instance*

*                keeping this pointer in the AVPacketList  to push into
decoding thread. *

2)  Whatever the frame we get  we send it to avcodec_decode_video2 (...
frameFinished, packet);
     ->  This API keeps internally the previous frames required to decode.
if it has sufficient packet to decode,
           it decodes, and sends back saying "You got complete picture".


Kindly correct me if i am wrong?





On Tue, May 27, 2014 at 9:20 PM, Joshua Kordani <jkordani at lsa2.com> wrote:

>  On 5/27/14 11:28 AM, wm4 wrote:
>
> On Tue, 27 May 2014 17:10:55 +0530
> sithruk sana <get2jils at gmail.com> <get2jils at gmail.com> wrote:
>
>
>  thanks for the reply.
>
> I am doing the same by queueing the packet  as described in dranger
> tutorial http://dranger.com/ffmpeg/ffmpegtutorial_all.html
>
>  This tutorial is prehistoric, and following it will cause you more pain
> than not. Many things in it are just wrong or uses deprecated APIs. I
> recommend pretending that this tutorial doesn't exist.
>
> Normally, libavcodec decodes one frame for one packet. But you need
> to deal with "codec delay": at first you won't get any decoded frames,
> even if you put in some packets. Only later (when enough frames are
> queued internally), you will get 1 decoded frame for 1 packet. (You also
> need to feed it null-packets at the end of the video to get the last
> frames.)
>
>  If I have a buffer of encoded units, which I know contains a complete
> frame of encoded input, are you saying that I may have to pass multiple
> sets of these before I receive the decoded results of the first buffer?
>
> Or are you saying that I can submit chunks of a frame's worth of encoded
> input, and (understandably) won't get a complete frame back until I pass in
> enough data for 1 frame?
>
> Does the term "packet" in your reply correspond to something specific, as
> in, one "packet" of h264 encoded data corresponds to one NALU, or do you
> mean, one "packet" refers to enough encoded data, no matter the encoder, to
> make one frame?
>
>
>  There are others reasons why it wouldn't output a frame. If the video
> frame is "damaged", you may need to set CODEC_FLAG2_SHOW_ALL or
> CODEC_FLAG_OUTPUT_CORRUPT (forgot which one) to make lavc output them.
> Also, it's possible to drop frames by setting skip_frame, but you
> probably don't use this.
>
>
>  this is useful, thank you
>
> Joshua Kordani
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140527/43e7a0e0/attachment.html>


More information about the Libav-user mailing list