[MEncoder-users] avi sync questions

Erik Slagter erik at slagter.name
Sun Apr 6 11:42:59 CEST 2008


Wes Morgan wrote:

> I've got a D-Link DSM-520 that I've been using for several years to play 
> videos that are both downloaded and personally ripped. Periodic firmware 
> updates are released, and there is a specific difference between version 
> 1.02 and higher releases... Any video I ripped with mencoder loses audio 
> sync when played. I submitted a sample video to D-Link and their response 
> was:
> 
>      We have checked your file. It seems that the timestamp of the MPEG4
>      video is different from that of the AVI header and the AVI timestamp
>      is the correct one.
> 
>      This make us to be in the delimma. Some others files are in the other
>      side. This is very difficult for a streaming player. We can not jump
>      randomly like the local player. We may add a sync key to reset the
>      timestamp. However, I believe that this will be a strange thing for
>      the end-users.
> 
> The person who sent me this response is very active in a forum thread 
> about the player and is obviously someone who does or has worked on the 
> firmware development team.
> 
> Does the claim make any sense? Is there any way I can prove or disprove 
> that these two timestamps disagree? If so, is there any way to fix them?

I am not all an expert on this (mpeg4-2 in avi) but at least I can tell 
you that AVI doesn't have timestamps at all, it does have a list of 
sample-numbers, though, for seeking but it's not the same as a 
timestamp. For example it can't handle variable frame rate material.

AFAIK mpeg4-2 video is not stored in PES-packets in AVI, but as a pure 
elementary stream. Elementary streams do not have associated timestamps.

So, at least the phrasing of this technical guy wrong.

I think he means this: you can play a file either by simply start 
playing the first video frame and the first audio frame, and at each 
"tick" continue with the next one. This is the (too) simple approach 
that ignores skew between video and audio which happens to be quite 
common. The right approach is to lookup each next group of frames in the 
frame list (in case of AVI) and start playing there. This handles a/v 
skew well, and this is the approach D-LINK should use.

BTW if you feed mencoder a complete DVD you may end up with a skewed a/v 
stream, indeed. The workaround would be to encode audio and video 
seperately, cut/add as much frames from/to the start of the audio/video 
streams so they are aligned and then multiplex these together. This will 
always play correctly, whether on a borked or a correct player.

AFAIK there is no option in mplayer and mencoder to do this for you, it 
really would be a nice-to-have, AFAICS it's really not difficult to 
implement.


More information about the MEncoder-users mailing list