Log in

View Full Version : AVISource() - audio length doesn't match ?


Kurtnoise
27th March 2009, 16:08
Hi,

Here is some infos from my input:
General
Complete name : E:\tt\file.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 350 MiB
Duration : 42mn 46s
Overall bit rate : 1 143 Kbps
Writing application : transcode-1.0.6

Video
Format : MPEG-4 Visual
Format profile : Streaming Video@L1
Format settings, BVOP : Yes
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (H.263)
Codec ID : XVID
Codec ID/Hint : XviD
Duration : 42mn 46s
Bit rate : 1 001 Kbps
Width : 624 pixels
Height : 352 pixels
Display aspect ratio : 16/9
Frame rate : 23.976 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.190
Stream size : 306 MiB (88%)
Writing library : XviD 1.2.1 (UTC 2008-12-04)

Audio
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 55
Codec ID/Hint : MP3
Duration : 42mn 46s
Bit rate mode : Variable
Bit rate : 130 Kbps
Minimum bit rate : 128 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Resolution : 16 bits
Stream size : 39.6 MiB (11%)
Alignment : Aligned on interleaves
Interleave, duration : 24 ms (0.58 video frame)
Writing library : LAME3.95
Encoding settings : ABR



the script:
AVISource("file.avi")
EnsureVBRMP3Sync()

and using it, I get this into Vdub File Information:
http://uppix.net/4/1/f/628d7fd15b5dc667a0fe11c3c0018.png (http://uppix.net/4/1/f/628d7fd15b5dc667a0fe11c3c0018.html)

and playing it through MPC-HC, I get the wrong duration too (43''16) and desync occurs.

So, what's wrong w/ AVISource & audio stream duration ?

Note 1: all is fine using DirectShowSource or FFmpegSource...
Note 2: I get wrong duration w/ or w/o EnsureVBRMP3Sync()
Note 3: Avisynth 2.58 - Vista 32bits

Inspector.Gadget
27th March 2009, 16:20
Might this be another example of the problem with VFW and B-frames? Are you using ffdshow_VFW as the decoder?

Kurtnoise
27th March 2009, 16:25
It's an audio issue not video...

IanB
27th March 2009, 22:52
The Audio and Video stream lengths are independent in AVI files, AviSource() preserves the distinction so you have the option to explicitly deal with it.

With compressed MP3 audio streams the MP3 data needs to be an integral number of MP3 packets. When you decompress this you end up with a slightly longer stream due to the last input MP3 packet having been padded. Also different codec have different strategies for dealing with truncated last input packet, some reject it, some fill with zeros.

In Avisynth you can easily truncate/pad the audio stream length to match the video stream length with a Trim(0, 0) statement.

Kurtnoise
28th March 2009, 08:53
ok...thanks for the clarification.

tebasuna51
28th March 2009, 12:11
...
With compressed MP3 audio streams the MP3 data needs to be an integral number of MP3 packets. When you decompress this you end up with a slightly longer stream due to the last input MP3 packet having been padded. Also different codec have different strategies for dealing with truncated last input packet, some reject it, some fill with zeros.

But the standard packets (audio frames) are 24 ms long, and the difference here is between 43:16.96 and 42:46, 30 seconds.

I think the problem is the VBR in avi.
The audio length is calculated like CBR 128 Kb/s (StreamSize/128 -> 43:16) but the real length must be calculated with 130 Kb/s (StreamSize/130 -> 42:46)

@Kurtnoise
The problem is solved with the Trim(0,0)?

Try, extracting the mp3 with VDMod, this .avs
v=AVISource("file.avi", audio=false)
a=NicMPG123Source("audioVBR.mp3")
AudioDub(v,a)

And check now the audio duration. NicMPG123Source check the full VBR.mp3 to know the exact duration and send the data to AviSynth

Kurtnoise
28th March 2009, 13:48
@Kurtnoise
The problem is solved with the Trim(0,0)?

yes...anyway, I'm not interested by streams extraction. ;)

tebasuna51
29th March 2009, 01:50
yes...anyway, I'm not interested by streams extraction. ;)
Yes, was only to test because I don't understand how a Trim(0,0) can solve 30 seconds of async.

Comatose
29th March 2009, 05:29
I guess it's because it refers to the video track, so by trimming to the length of the video track you would remove excess audio. (whether or not that would fix async I don't know, but it would make them the same length)

Or at least that's my understanding of it.