[MPlayer-users] mencoder issue with hr-edl-seek

XY Smith xysmith at live.com
Sun Sep 14 08:33:20 CEST 2008


Hello,

I recently used my Hauppage PVR-350 to record about 14 hours of television. As a matter of cleaning it up and keeping what's interesting and getting rid of what's not (commercials) I attempted to use EDL with mencoder. Using the normal EDL seek granularity works fine but lacks a bit of precision when clipping to specific frames.

With -hr-edl-seek enabled I discovered that it would always eventually lead to this message repeating until I hit ctrl-c:

Too many video packets in the buffer: (4096 in 7885352 bytes).


I checked out the SVN version and built from that. Same result. The source material is MPEG-II from a hauppage card. The destination is msmpeg4 as per this command line:

~/m/mplayer/mencoder -edl edl.test -hr-edl-seek -endpos 35 -ovc lavc -oac mp3lame -lameopts cbr:br=1
28:vol=3:mode=3 -lavcopts vcodec=msmpeg4:vbitrate=3000:vhq:keyint=250 -vf pp=lb,crop=704:365:8:60,sc
ale=624:324 -o xyz.avi tv.mpg

The edl file:

0.000 15.000 0
30.000 45.000 0
60.000 75.000 0

Output:

MEncoder dev-SVN-r27605-4.1.1 (C) 2000-2008 MPlayer Team
CPU: Intel(R) Core(TM)2 CPU          6300  @ 1.86GHz (Family: 6, Model: 15, Stepping: 6)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2

success: format: 0  data: 0x0 - 0x2ee0000
MPEG-PS file format detected.
VIDEO:  MPEG2  720x480  (aspect 2)  29.970 fps  6000.0 kbps (750.0 kbyte/s)
[V] filefmt:2  fourcc:0x10000002  size:720x480  fps:29.970  ftime:=0.0334
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 224.0 kbit/14.58% (ratio: 28000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [scale w=624 h=324]
Opening video filter: [crop w=704 h=365 x=8 y=60]
Crop: 704 x 365, 8 ; 60
Opening video filter: [pp=lb]
==========================================================================
Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
VDec: vo config request - 720 x 480 (preferred colorspace: Mpeg PES)
[PP] Using external postprocessing filter, max q = 6.
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
VDecoder init failed :(
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2)
==========================================================================
MP3 audio selected.
Read 3 EDL actions.
VDec: vo config request - 720 x 480 (preferred colorspace: Planar YV12)
[PP] Using external postprocessing filter, max q = 6.
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
SwScaler: reducing / aligning filtersize 6 -> 8
SwScaler: reducing / aligning filtersize 6 -> 8
SwScaler: reducing / aligning filtersize 6 -> 5
SwScaler: reducing / aligning filtersize 6 -> 5
[swscaler @ 0x8ca3830]BICUBIC scaler, from yuv420p to yuv420p using MMX2
[swscaler @ 0x8ca3830]using 8-tap MMX scaler for horizontal luminance scaling
[swscaler @ 0x8ca3830]using 8-tap MMX scaler for horizontal chrominance scaling
[swscaler @ 0x8ca3830]using n-tap MMX scaler for vertical scaling (YV12 like)
[swscaler @ 0x8ca3830]704x365 -> 624x324
videocodec: libavcodec (624x324 fourcc=33766964 [div3])
[VE_LAVC] High quality encoding selected (non-realtime)!
New_Face failed. Maybe the font path is wrong.: 15.02  A: 14.98
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
New_Face failed. Maybe the font path is wrong.
Please supply the text font file (~/.mplayer/subfont.ttf).
subtitle font: load_sub_face failed.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos:   0.8s     23f (23%)  0.00fps Trem:   0min   1mb  A-V:0.067 [0:128]
Skipping frame!
EDL SKIP: Start: 30.00  End: 45.00   Current: V: 45.01  A: 44.98     6:128]
Too many video packets in the buffer: (4096 in 7865224 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.

Too many video packets in the buffer: (4096 in 7865224 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.
Pos:  15.0s    451f (81%) 64.76fps Trem:   0min   4mb  A-V:0.030 [1825:128]
Too many video packets in the buffer: (4096 in 7865224 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.
Pos:  15.0s    452f (81%) 64.79fps Trem:   0min   4mb  A-V:0.033 [1827:128]
Too many video packets in the buffer: (4096 in 7865568 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.
Pos:  15.1s    453f (81%) 64.83fps Trem:   0min   4mb  A-V:0.037 [1829:128]
Too many video packets in the buffer: (4096 in 7864620 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.

Too many video packets in the buffer: (4096 in 7864620 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.
Pos:  15.1s    454f (81%) 64.84fps Trem:   0min   4mb  A-V:0.040 [1831:128]
Too many video packets in the buffer: (4096 in 7864248 bytes).
Maybe you are playing a non-interleaved stream/file or the codec failed?
For AVI files, try to force non-interleaved mode with the -ni option.

.....



Flushing video frames.
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.

Video stream: 1922.613 kbit/s  (240326 B/s)  size: 4025487 bytes  16.750 secs  508 frames

Audio stream:  128.000 kbit/s  (16000 B/s)  size: 238848 bytes  14.928 secs

I'm using CentOS 5 with Gcc 4.1:

[user at e6300 nnn]$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)

Additional investigation showed that the initial skip works grand (0 - 15 sec). Then The first 15 seconds of transcoded video works ok (15 - 30 sec). The second skip works (30 - 45 sec), at this point mencoder get stuck trying to read audio packets in this loop in mencoder.c, lines 1218 - 1240:

                        int sz = 0;
                        while(1)
                        {
                                len = 0;
//printf("\n2. -> %d / %x\n", aencoder->stream->buffer_len,  aencoder->stream->buffer);
                                if(! sz)
                                        sz = aencoder->get_frame_size(aencoder);
//{ static int xy_sz_count = 0; if (sz == 0) { xy_sz_count++; if (xy_sz_count> 10) exit(0);} }
//sz = 384;
                                if(sz> 0 && mux_a->buffer_len>= sz)
                                {
                                        len = sz;
                                        break;
                                }
                                len = dec_audio(sh_audio,aencoder->decode_buffer, aencoder->decode_buffer_size);
//printf("2a -> %d (%d / %d) ::::\n",len, sz, mux_a->buffer_len );
                                if(len <= 0)
                                {
                                        len = 0;
                                        break;
                                }
                                len = aencoder->encode(aencoder, mux_a->buffer + mux_a->buffer_len, aencoder->decode_buffer, len, mux_a->buffer_size-mux_a->buffer_len);
                                mux_a->buffer_len += len;
//printf("2b -> %d ::::\n",len);
                        }

The first time through the call to aencoder->get_frame_size() results in a value of 384. After the second time through the edl code (edl_seek() / slowseek()) after having written some data to the output file, the return from aencoder->get_frame_size() is 0, as such sz is zero and this loop will never exit, at least not before reaching the end of the file. Digging through the code it appears that this is happening in mp_get_mp3_heard(). Enabling -msglevel demuxer=9 generates the message "head_check failed" from libmpdemux/mp3_hdr.c, mp_get_mp3_header. A bit of added code to dump the contents of hbuf upon entry to mp_get_mp3_header and the contents look nothing like the header check expects to find:

ed ff 80 fc c3 33 c8 a3 d2 3d 25 55 61 86 d8 .... 

It appears that the slow seek somehow gets the audio packet stream out of sync. In the code I've pasted above you'll see that I added in a simple sz = 384;, with 384 being the value that is returned prior to everything going to pieces. With that included the conversion process works fine with the resulting avi having proper audio, video and everything in sync. Meaning that dec_audio and subsuquent functions manage the synchronziation problem that is throwing off get_frame_size(). I've not had much luck so far digging out where the actual problem lies, but thought I'd throw it out and see if someone who knows the code better than I has any ideas?
_________________________________________________________________
Get more out of the Web. Learn 10 hidden secrets of Windows Live.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008


More information about the MPlayer-users mailing list