[MEncoder-users] How to change the audio timestamps

A. Schmid sahib at phreaker.net
Tue May 27 23:25:35 CEST 2008


Jorge Peixoto de Morais Neto wrote:
> When I capture video from my TV card, I get a huge number of
> duplicated frames and skipped frames. To avoid it, I use the option
> noskip. But then a weird problem happens: a steadily increasing delay
> between the audio and the video. 

Nothing weird about this! If audio and video aren't exactly in sync (To 
be more precise: If audio and video are not in sync with real time. AVI 
only allows fixed fps and a fixed number of audio samples per second.), 
then mencoder _needs_ to skip/duplicate frames.
With -noskip, you prevent skips, that leads to increasing A-V delay.

> However, I don't like the idea of irreversibly changing the PCM audio
> before encoding to vorbis. Can I make a "soft tempo" with mencoder?
> 
> Or, can I avoid this 0.1% discrepancy in the first place?
> 
> May this 0.1% discrepancy have anything to do with the famous 0.1%
> difference between the "natural" framerate of 30 and the real
> framerate of 30 / 1.001?

Probably not. I have the same problem with PAL captures (25 fps).

> About the skipped/duplicated frames: another poster suggested me to
> mess with .asoundrc, but I have not yet studied ALSA. So messing with
> .asoundrc may (or may not) solve my skipped/duplicated frames problem
> in the future, but I already have video with a 0.1% sync discrepancy

I suspect the other poster was me ;-)
And yes, I could solve the skips-and-duplicates problem (which led to a 
jerky video) with the .asoundrc modifications. But the audio-video 
drifting is still there :-/

I really don't know what to do about this...
Perhaps measure the delay and adjust the capturing fps accordingly?

I don't even know why it happens. Is ALSA outputting too much/few 
samples per second? If captured samples have a slightly different 
duration compared to the playback, you only _can_ geht drift...

The only solution could be to make mencoder use a reliable time source 
(system clock instead of number of sound samples) to synchronize audio 
and video. Something like -autosync for mencoder.
Or fix ALSA...

> A quick example of the duplicate frames and skipped frames I get when
> I omit noskip:
> 
> Pos:   1.0s     32f ( 0%) 24.17fps Trem:   0min   0mb  A-V:0.000 [61231:0]
> Skipping frame!
> Pos:   1.0s     33f ( 0%) 20.26fps Trem:   0min   0mb  A-V:0.000 [61231:705]
> Skipping frame!
> Pos:   1.2s     39f ( 0%) 23.04fps Trem:   0min   0mb  A-V:0.000 [61682:705]
> 1 duplicate frame(s)!
> Pos:   1.3s     41f ( 0%) 23.85fps Trem:   0min   0mb  A-V:0.000 [60266:705]
> Skipping frame!
> Pos:   1.3s     43f ( 0%) 24.78fps Trem:   0min   0mb  A-V:0.000 [60381:705]
> 1 duplicate frame(s)!

These are clearly too much skips (and duplicates between them!). I guess 
the resulting video is horribly jerky?
Have you tried to use a codec other than raw audio and video?

Regards
Alex




More information about the MEncoder-users mailing list