[MEncoder-users] Encoding with libx264 cuts off audio at the end

Marcus Blumhagen marcus.blumhagen at web.de
Tue Sep 29 22:49:24 CEST 2009


I use the latest mencoder from svn and the latest libx264 from git.

When I encode a file the audio is cut off at the end. The cut off
length seems to correspond to the rc-lookahead value off x264. I
noticed, that at the beginning of the encoding process the time
counter stand still until the framecounter has gone up to the number
of frames set for rc-lookahead (+x frames, depending on the thread
count as it seems), like this:

$ mencoder -oac copy -ovc x264 -x264encopts rc-lookahead=250 -o outfile.avi infile.mkv
[...]
Pos:   0.1s    254f (98%) 62.72fps Trem:   0min   0mb  A-V:-0.030 [0:0]
       ^^^^    ^^^^
At the the end of the encoding process there is a difference between the
time counter of mencoder and the time in the stats of x264 also
reflected by the differnce in Video Stream length and Audio Stream
length:

Pos:  21.1s    763f (99%)  2.61fps Trem:   0min   4mb  A-V:-0.042 [1416:192]
Flushing video frames.
Writing index...
Writing header...
ODML: vprp aspect is 16:9.
Setting audio delay to 0.048s.

Video stream: 1382.578 kbit/s  (172822 B/s)  size: 5499792 bytes 31.823 secs  763 frames
                                                                 ^^^^^^
Audio stream:  192.000 kbit/s  (24000 B/s)  size: 519552 bytes  21.648 secs
                                                                ^^^^^^

The source frame rate in the example is 23.976 fps, multiplied by the
time difference its roughly 250.
It seems as if at the beginning mencoder feeds frames to x264 but does
not start the audio coding until the frame counter has reached the
value of rc-lookahead. But when the video is fully encoded the audio
encoding is stopped immediatly. When you play such a file the audio is
in sync but cut off at the end. It also happens, if you do not set
rc-lookahead explicitly, because the default is 40 frames.

Looks like a bug to me, but maybe I am missing something. I searched
the man page for something that might continue the audio encoding. I
believe I have seen such an option in there a long time ago, but it
might also have been the doc of another tool.


I´d appreciate any help on this.

-- 
Marcus Blumhagen

"Any intelligent fool can make things bigger, more complex, and more
violent. It takes a touch of genius -- and a lot of courage -- to move
in the opposite direction."
                                                      -- Albert Einstein


More information about the MEncoder-users mailing list