videovideo-streamingh.264rtp

Time stamps of RTP\H.264


I have a question about I,P,B frames and their time stamps.

I know that the timestamp of RTP packets suppose to be increased monotonically. I also know (correct me if I'm wrong) that in h.264 B_5 frame can be transmitted before P_4 frame but displayed after (P_4 and then B_5) so the decoder will use the B frame to decode the P frame.

I have pcap capture of RTP\H.264 stream and I can see that the time stamps increases\decreases... and not monotonically increases.

So my question is what values the RTP packets (I,P,B frames) should get on h264 transmission?

I will be happy for some clarification about that matter.


Solution

  • I know that the timestamp of RTP packets suppose to be increased monotonically.

    According to RFC 3550

    Consecutive RTP packets MAY contain timestamps that are not monotonic if the data is not transmitted in the order it was sampled, as in the case of MPEG interpolated video frames. (The sequence numbers of the packets as transmitted will still be monotonic.)

    Further, your statement is not correct

    and I also know (correct me if I wrong) that in h.264 B_5 frame can be transmitted before P_4 frame but displayed after (P_4 and then B_5) (so the decoder will use the B frame to decode the P frame).

    Firstly, B-frames are dependent on the I or P-frames i.e. The B-frame is not used to decode the P-frame, but the other way around -> B5 depends on P4. There is no reason to send B5 before P4. Note that this depends on your GOP structure.

    If media samples are transmitted in decoding order (this depends on the packetization mode defined in RFC6184) and the GOP is something like I-B1-B2-B3-P, these frames would be transmitted I-P-B2-B1-B3.

    If using the interleaved packetization mode, the Decoding Order Number (DON) must be used to restore the decoding order. You can read up about it in RFC 6184.