[Ffmpeg-devel] MPEGTS muxer problem [on behalf of lucabe72]

Luca Abeni lucabe72
Fri Nov 17 17:10:25 CET 2006


Hi Baptiste,

On Fri, 2006-11-17 at 16:40 +0100, Baptiste Coudurier wrote:
[...] 
> > +    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
> > +        mpegts_write_pes(s, st, buf, size, pkt->pts, pkt->dts);
> > +        return 0;
> > +    }
> > +
> > +mpegts_write_pes(s, st, buf, size, pkt->pts, AV_NOPTS_VALUE);
> > +return 0;
> >      max_payload_size = DEFAULT_PES_PAYLOAD_SIZE;
> >      while (size > 0) {
> >          len = max_payload_size - ts_st->payload_index;
> 
> return in the middle of the function ?
Yes, I told that the patch is wrong in many ways :)

Basically, mpegts_write_packet() is trying to buffer the encoded stream
until the PES size is bigger than DEFAULT_PES_PAYLOAD_SIZE, but this
creates a bad interleaving of the audio and video streams (I think the
problem is that a PES is outputed "all at once", while the ts packets of
audio and video PESs should be interleaved). And vlc complains about
this (vlc is not the only one complaining... I've seen DVB-S and T
decoders skipping video frames because of this).

So, my "stupid solution" is to just avoid buffering data, and to write
it down as soon as it arrives, reducing the size of the PES (so, I write
a PES per mpegts_write_packet() call). I know this is wrong (as I wrote,
this is not a submission), but it's the only simple solution I found (at
least, it shows where the problem is :).
I think the PS muxer in libavformat implements the correct solution.


			Thanks,
				Luca
-- 
_____________________________________________________________________________
Copy this in your signature, if you think it is important:
                               N O    W A R ! ! !





More information about the ffmpeg-devel mailing list