[vlc-devel] Re: [PATCH] mpeg4 packetizer

Gildas Bazin gbazin at altern.org
Thu Mar 10 16:54:41 CET 2005


On Wednesday 09 March 2005 22:54, Andreas Junghans wrote:
>
...
> 
> After I generated PCRs artificially, the stream sort of worked. Audio 
> was fine, but video was stuttering badly (looking "scratched" with some 
> sequences shown too early and some too late). However, transcoding the 
> stream with ffmpeg worked fine, so it seemed like the stream was OK. A 
> few long debug sessions later, it turned out that there are problems in 
> modules/packetizer/mpeg4video.c - the timestamps are simply not handled 
> correctly (even in the latest svn version).
> 

The mpeg4video packetzier behaves just fine, it's your stream that is 
completely broken.
In the timestamps log I included at the end of the mail, you'll see that 
your stream doesn't follow the MPEG standard.

1 - It timestamps every frame (which is fine) but the timestamps are not 
valid (hence your hack to ignore them by only taking them when a GOP 
appears).
2 - An other obvious mistake is that DTS and PTS are mandated by the MPEG 
spec to be equivalent for B frames (which clearly isn't the case here).

>
> Attached is a patch (against the current trunk, freshly checked out) 
> that fixes playback of the ConvertX streams for me (at least after PCRs 
> have been inserted). It's basically a port of ffmpeg's mpeg4 timestamp 
> handling to VLC's mpeg4 packetizer. However, it's not quite ready since 
> I've completely ignored DTS for now. I'd appreciate any insight into 
> how the decoding timestamps are used by VLC. Simply setting them to the 
> same value as PTS seems to work just fine, so that's what I'm currently 
> doing. It would be great if someone could explain to me how these are 
> actually used, so I could come up with a proper patch.
> 

This patch is unacceptable because:
1 - It ignores the frames' PTS/DTS except on GOP boundaries. That's not 
acceptable simply because the PTS and DTS information passed on from the 
demuxer should always take precedence over timestamp interpolation.
2 - The timestamp interpolation is not based on current/previous DTS anymore 
which will break demuxers which don't have any PTS information (eg. avi).

The current timestamping in the mpeg4video packetizer isn't broken at all 
(not surprising since it timesamps the frames based on the spec defined in 
the MPEG standards).

Here is a log I got when playing your stream.
"new frame, pts: xx, dts: xx" gives you the timestamps that come from your 
stream.
"interp pts: xx" gives you our interpolated value for this frame.
"corrected interp pts: xx" gives you the final value that we choose and pass 
on to the decoder.

[00000315] packetizer debug: new frame, pts: 1110468858059776, dts: 
1110468858093143 (144436608)
[00000315] packetizer debug: interp pts: 1110468858159875, I-frame
[00000315] packetizer debug: corrected interp pts: 1110468858059776
[00000315] packetizer debug: new frame, pts: 1110468858093143, dts: 
1110468858126509 (144264856)
[00000315] packetizer debug: interp pts: 1110468857993043, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858093143
[00000315] packetizer debug: new frame, pts: 1110468858126509, dts: 
1110468858159876 (144442648)
[00000315] packetizer debug: interp pts: 1110468858126509, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858126509
[00000315] packetizer debug: new frame, pts: 1110468858159876, dts: 
1110468858193243 (144558288)
[00000315] packetizer debug: interp pts: 1110468858259975, P-frame
[00000315] packetizer debug: corrected interp pts: 1110468858159876
[00000315] packetizer debug: new frame, pts: 1110468858193243, dts: 
1110468858226609 (144558288)
[00000315] packetizer debug: interp pts: 1110468858093143, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858193243
[00000315] packetizer debug: new frame, pts: 1110468858226609, dts: 
1110468858259976 (145179312)
[00000315] packetizer debug: interp pts: 1110468858226609, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858226609
[00000315] packetizer debug: new frame, pts: 1110468858259976, dts: 
1110468858293343 (144234136)
[00000315] packetizer debug: interp pts: 1110468858360075, P-frame
[00000315] packetizer debug: corrected interp pts: 1110468858259976
[00000315] packetizer debug: new frame, pts: 1110468858293343, dts: 
1110468858326709 (144234136)
[00000315] packetizer debug: interp pts: 1110468858193243, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858293343
[00000315] packetizer debug: new frame, pts: 1110468858326709, dts: 
1110468858360076 (143642376)
[00000315] packetizer debug: interp pts: 1110468858326709, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858326709
[00000315] packetizer debug: new frame, pts: 1110468858360076, dts: 
1110468858393443 (144234136)
[00000315] packetizer debug: interp pts: 1110468858460175, P-frame
[00000315] packetizer debug: corrected interp pts: 1110468858360076
[00000315] packetizer debug: new frame, pts: 1110468858393443, dts: 
1110468858426809 (144234136)
[00000315] packetizer debug: interp pts: 1110468858293343, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858393443
[00000315] packetizer debug: new frame, pts: 1110468858426809, dts: 
1110468858460176 (144264856)
[00000315] packetizer debug: interp pts: 1110468858426809, B-frame
[00000315] packetizer debug: corrected interp pts: 1110468858426809

>    Andreas Junghans
> 
> 

-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html



More information about the vlc-devel mailing list