[MEncoder-users] Endless loop with -hr-edl-seek

Oded Shimon ods15 at ods15.dyndns.org
Fri May 20 07:16:07 CEST 2005


On Thu, May 19, 2005 at 08:41:31PM +0200, Thorsten Pferdek?mper wrote:
> Hi,
> this is perhaps not that important, but it is a little but ugly, because 
> mencoder stops reacting at all.
> I reencoded a file with mencoder using edl and -hr-edl-seek. The file had 
> sound, but the sound was a little bit shorter than the video. The edl did cut 
> off the last few minutes of the video.
> In this case, mencoder seems always to enter an endless loop. 
> I had a close look at the coding and here is my idea why this is like that: In 
> mencoder.c, function edl_seek, the loop which resyncs audio checks the 
> variable a_pts. When there is no audio left (I assume), this variable does 
> not change any more. Perhaps the loop should be left if a_pts stops 
> changing...

You're right. Does this fix it?

- ods15
-------------- next part --------------
Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.282
diff -u -r1.282 mencoder.c
--- mencoder.c	7 May 2005 14:50:14 -0000	1.282
+++ mencoder.c	20 May 2005 05:14:07 -0000
@@ -1597,15 +1597,16 @@
         if (sh_audio) {
             a_pts = d_audio->pts + (ds_tell_pts(d_audio) - sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
             while (sh_video->pts > a_pts) {
+                int len;
                 if (mux_a->h.dwSampleSize) {
-                    int len;
                     len = mux_a->wf->nAvgBytesPerSec * (sh_video->pts - a_pts);
                     len/= mux_a->h.dwSampleSize; if(len<1) len=1;
                     len*= mux_a->h.dwSampleSize;
-                    demux_read_data(sh_audio->ds,mux_a->buffer,len);
+                    len = demux_read_data(sh_audio->ds,mux_a->buffer,len);
                 } else {
-                    ds_get_packet(sh_audio->ds,(unsigned char**) &mux_a->buffer);
+                    len = ds_get_packet(sh_audio->ds,(unsigned char**) &mux_a->buffer);
                 }
+                if (len <= 0) break; // EOF of audio.
                 a_pts = d_audio->pts + (ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
             }
         }


More information about the MEncoder-users mailing list