[MPlayer-dev-eng] mencoder's fails to av-sync ASF with large WMA packets

Martin Devera martin.devera at cdi.cz
Thu Mar 12 01:07:41 CET 2009


Hello,

I reported this in bug 1416, in meanwhile I found the culprit but
it seems as more tricky mencoder bug.

mencoder.c line about 1380:

a_pts=d_audio->pts;
a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps

here it tries to compute a_pts as last stream pts mark plus decoded 
bytes. But in my demostream (see ftp) there are 6kB WMA packets, each
stores 370ms of audio.
Resulting AVI has bad audio sync by about 300ms.

Now, ds_tell_pts(d_audio) always return 5975 which is whole audio packet
len and sh_audio->a_in_buffer_len is zero.
Thus there is no way to set correct a_pts and about 10 videoframes has
the same a_pts. And it is bad pts (d_audio->pts+5975) - it points to end
of current audio block.
This seems to be fundamentaly broken and you can see it only with large
audio packets.

I tried:
static double last_pts=0,off=0;
       a_pts=d_audio->pts;
       if (last_pts != a_pts) {
               last_pts = a_pts; off=0;
       } else { off+=0.033; a_pts+=off; }

and it fixes the problem for me - but what is the correct solution !?
Probably one should use a_mux packets for av sync when audio packets
are timewise longer than video rate ?




More information about the MPlayer-dev-eng mailing list