[MPlayer-users] A-V-sync in mencoder

Ville Saari 113762 at foo.bar.org
Tue Mar 16 12:15:55 CET 2004


Mplayer adjusts the video speed to keep audio-sync, but mencoder
has to resample the video to fixed output framerate and does it by
skipping or duplicating frames. This causes ugly jumps in the video
so I was wondering if it would be feasible to implement an option to
resample the audio instead?

Sudden changes of the audio speed would of course be unacceptable,
but if the acceleration or deceleration is kept low enough, then I
believe it wouldn't be perceptible. Unlike the frame skips that are
almost always clearly visible and have become kind of a trade mark
of mencoder-generated files.

This would have several advantages over the frame skipping/duplicating:

- Video speed could be changed during the encoding. I could for example
  use -fps 25 -ofps 24 to slow PAL-movies down to their original film
  speed with no need to worry about audio sync.

- Mplayer's -speed option could be made available for mencoder too.
  -speed 0.96 would then be equivalent to the previous example. As long
  as the used video codec accepts the resulting frame rate.

- There would be no need to encode dummy audio on the first pass of a
  two pass encoding, because the audio would have no effect on video.

- The number of frames in the mencoded file would match the original
  exactly so the frame numbers for -frames, vrc_override etc. would
  be unambiguous.

Mencoder also seems to be quite eager to rapidly skip several frames near
the beginning on the encoding. This would suggest that the beginnings of
the video and audio stream have different time stamps on most files.
Is it so or is it a bug in mencoder?

If the input file is to blame, then it would be better to sync the
beginning by prepending silence to the audio. If the audio starts earlier
than video, then a question arises whether black frames should be prepended
to the video instead of cutting the audio? However in most cases the
beginning of the audio is quite silent anyway, so it could be safely cut.
A command line option could then be used to force black frames if they are
really needed. Perhaps -ss with negative offset.

-- 
 Ville




More information about the MPlayer-users mailing list