[FFmpeg-user] Decoding B-frames

David Cassany Viladomat david.cassany at i2cat.net
Thu Jun 26 10:26:57 CEST 2014

Hi all,

Maybe some of you can help me with some doubts I have. I'm building a C++
decoder for H264 using libavcodec, I wanna decode a network stream, so I am
decoding NAL units I receive by RTP. It's been a pretty straigh forward to
go through the API and decode frames. Basically I use "CODEC_CAP_TRUNCATED"
to feed "avcodec_decode_video2" NAL by NAL rather than frame by frame. Up
to here every is going fine unless I receive NALs from a Bframe.

After some digging I saw some examples about how to deal with the PTS and
DTS *after* decoding a frame in order to sort decoded frames according the
PTS. I have the feeling that in the examples I saw they assume frames in
DTS order. So, my question is, should I assume that I receive always frames
in DTS order? Can I get DTS or PTS form the AV_pkt before running

I am not decoding from any container, I am receiving a RAW H264 standard
stream from RTP, so I get NAL units one by one.

Thanks in advance fo rany advice,

More information about the ffmpeg-user mailing list