Hi, On 2/18/2009 3:58 PM, gmail wrote: >> On Fri, 23 Jan 2009 04:15:21 -0500, Bogdan Coanda >> <bogdan.coanda at gmail.com> wrote: >>> I'm currently working on a project decoding mpeg2ts streams, and my >>> problem is if can anyone explain to me why the PTS and DTS values >>> seem to be inverted - each packet returned to me by avcodec_decode_video >>> has the DTS in increasing order, but the PTS in every third packet is >>> out of order. >> This confused the heck out of me when I was first learning libav. The key >> is to realize that the PTS of the packet you give to the decoder is NOT >> the PTS of the frame it hands back to you. You hand the packets to it in >> DTS order, and it hands the frames to you in PTS order. >> >> So then how can you know when to display the frame? If you look into >> ffplay, you will see a trick where a custom frame allocation function is >> used, and the PTS of the current packet is read out of a global variable >> and attached to the '->opaque' of the frame. Then later when the frame >> comes out of the decoder the PTS is retrieved from that pointer. To avoid >> the global variable, you can use the ->opaque of the AVFormatContext >> (which is accessible in the allocation function). > > I am having the same problem, Michael suggests in other emails, using the > dranger method used in his > tutorial.(http://www.dranger.com/ffmpeg/tutorial05.html) The article > suggests overriding the get_buffer and release_buffer functions to pass the > PTS around. Unfortunately the myGetBuffer (the override) does not get called > until the decoder has the first frame out. By then, it has already received > 13 frames. After that it gets called after every frame has been decoded. See > the output below:
The new method is to use AVCodecContext->reordered_opaque like done in ffplay. Check the source. -- Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA checking for life_signs in -lkenny... no FFmpeg maintainer http://www.ffmpeg.org _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
