View Full Version : Mencoder encodes h264 too fast (A/V issue)

11th May 2007, 00:20
Hi, I'm using mencoder for my Xbox360 to play DivX and alike. Some series use MKV as a container and most of them use H264 for video. The issue arrises when transcoding a H264 stream from a MKV file to MPEG2. For some reason the video stream plays faster than the audio. It looks like the audio is playing at the correct speed (correct pitch etc) but the video stream is getting further out of sync by the second: after one minute we already have a lag of a few seconds.

This is an example of how mencoder is called:
mencoder -delay 0 -oac lavc -srate 48000 -af lavcresample=48000 -of mpeg -mpegopts format=dvd -o "[AniYoshi]_Kaze_no_Stigma_-_03_[0A816EBA].360" -ovc lavc -vf scale=704:400,expand=784:448,harddup -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=8000:keyint=15:aspect=16/9:acodec=mp2:abitrate=320 -ofps 24000/1001 -slang eng -subpos 92 -alang jp -alang jpn "[AniYoshi]_Kaze_no_Stigma_-_03_[0A816EBA].mkv"

I tried to rule out every flag for causing this but even with the manual as a source I can't figure out why it does this.

Like I said, AFAIK I only run into this problem with MKV+H264, maybe H264 in general but I can't test that (what other containers can do H264?).

I tried this with multiple versions of mencoder under Windows and the latest version on linux - make no difference.

One thing that worried me is the amount of skipped frames - I see errors every 0.3 to 0.4 seconds. But even with 2.5 dropped frames per second, shouldn't the softskip options fix this? I tried different anti-skipping options and it didn't help.. Or I mixed the wrong ones...

For example:
Pos: 63.2s 1681f ( 6%) 50.42fps Trem: 8min 360mb A-V:0.083 [2637:320]
Skipping frame!
[h264 @ 0xb83b20]no frame!50.44fps Trem: 8min 360mb A-V:0.046 [2637:320]
Error while decoding frame!
[h264 @ 0xb83b20]no frame!50.47fps Trem: 8min 360mb A-V:0.050 [2637:320]
Error while decoding frame!
Pos: 63.2s 1685f ( 6%) 50.50fps Trem: 8min 360mb A-V:0.017 [2637:320]
1 duplicate frame(s)!
Pos: 63.9s 1701f ( 6%) 50.53fps Trem: 8min 362mb A-V:0.083 [2621:320]
Skipping frame!
Pos: 64.3s 1711f ( 6%) 50.59fps Trem: 8min 360mb A-V:0.083 [2615:319]
Skipping frame!
Pos: 64.7s 1721f ( 6%) 50.64fps Trem: 8min 362mb A-V:0.083 [2605:320]
Skipping frame!
[h264 @ 0xb83b20]no frame!50.66fps Trem: 8min 362mb A-V:0.046 [2605:320]
Error while decoding frame!
[h264 @ 0xb83b20]no frame!50.69fps Trem: 8min 362mb A-V:0.050 [2605:320]

11th May 2007, 11:31
try adding this switch
-MC 0

14th May 2007, 17:48
It worked! Awesome, thanks a lot - i've been trying to get this fixed for months! :D