Wrong PTS when streaming an Mpeg2 stream with B-Frames
Posted: 17 Feb 2015 08:10
When streaming Mpeg-2 stream that has B-Frames, the PTS that is set for the I and P frames is wrong.
With version 2.0.8, these PTS values were not set at all, and with the 2.1.x (2.1.2 and 2.1.5-latest), the PTS is set as the DTS, which is wrong!
With a stream with B-Frames, the decoding order is different than the presentation(display) order. IBBPBBPBB are displayed BBIBBPBBP.
This can be seen by the "temporal reference" mpeg2 header field which carry the actual timing-order of the frames.
This is how it should be:
Stream frames: I B B P B B P B B P B B
Temp. Ref: 1 2 0 4 5 3 7 8 6 10 11 9
DTS(ms): 0 33 66 100 133 166 200 233 266 300 333 366
PTS(ms): 66 0 33 166 100 133 266 200 233 366 300 333
With version 2.0.8, these PTS values were not set at all, and with the 2.1.x (2.1.2 and 2.1.5-latest), the PTS is set as the DTS, which is wrong!
With a stream with B-Frames, the decoding order is different than the presentation(display) order. IBBPBBPBB are displayed BBIBBPBBP.
This can be seen by the "temporal reference" mpeg2 header field which carry the actual timing-order of the frames.
This is how it should be:
Stream frames: I B B P B B P B B P B B
Temp. Ref: 1 2 0 4 5 3 7 8 6 10 11 9
DTS(ms): 0 33 66 100 133 166 200 233 266 300 333 366
PTS(ms): 66 0 33 166 100 133 266 200 233 366 300 333