PDA

View Full Version : a/v sync for AVI with ABR MP3


The Rabbit
5th March 2004, 18:41
Hi,

I'm writing a media player to playback AVI files. Basically it plays AVI with CBR and normal VBR MP3 with no problems. Now I encountered some files with MP3 encoded with so-called Average Bitrate. My player suffers from some sync problems on these files.

My player treats the ABR file as a CBR file, so it calculates the time stamp for each audio chunk based on consumed bytes. It results in incorrect audio time stamps here and there, so video is syncing to an incorrect time.

Is there any way to calculate the time stamp for each audio chunk correctly?

Also, is it possible to distinguish ABR file from CBR file based on information in AVI's headers?

Any help is highly appreciated.
Thanks.

alexnoe
9th March 2004, 00:09
ABR is VBR

The Rabbit
9th March 2004, 02:55
Originally posted by alexnoe
ABR is VBR
Yes I know it's VBR, but it doesn't follow the "one frame per chunk"
custom of putting VBR MP3 into AVI. How do I calculate the exact
time stamp for each audio chunk? Is it possible?

Thanks

alexnoe
9th March 2004, 09:25
Then the file is broken. If you want to read such broken files, you need to parse the entire file before playing it.

You should extract the audio stream and mux it again, as VBR.

The Rabbit
16th March 2004, 06:41
Originally posted by alexnoe
Then the file is broken. If you want to read such broken files, you need to parse the entire file before playing it.

You should extract the audio stream and mux it again, as VBR.

Yes I also suspect this file is broken, but some other player can play it without sync problems, and I'm wondering how it's done. I don't think that player has parsed the entire file before playing it.

Here're some information from the header:
Video:
dwInitialFrames = 0 (0x0)
dwScale = 1000 (0x3e8)
dwRate = 23976 (0x5da8)
dwStart = 0 (0x0)
dwDuration = 3413 (0xd55)
dwSampleSize = 0 (0x0)
Audio:
dwInitialFrames = 0 (0x0)
dwScale = 1 (0x1)
dwRate = 16019 (0x3e93)
dwStart = 0 (0x0)
dwDuration = 1 (0x1)
dwSampleSize = 1 (0x1)

wFormatTag = 0x0055
nChannels = 2
nSamplesPerSec = 48000 (0xbb80)
nAvgBytesPerSec = 16250 (0x3f7a)
nBlockAlign = 1 (0x1)
wBitsPerSample = 0 (0x0)

Also I've checked and is quite sure that the audio part is not allocated as "one frame per chunk", but is really VBR, and the average bitrate is about 16019 bytes/sec.

Could there be any secret inside the file that I don't know?

Thanks.