Log in

View Full Version : Weird problem with 44.1 kHz DV and AviSynth


rling
28th May 2007, 08:04
Hi DV-ers,

I captured a DV tape as a AVI type 1, using DVIO. It plays fine in ZoomPlayer and WMP.

I imported it into VD using the AviSynth statement:
DirectShowSource("file.avi")
But the audio plays back too slow. The Information panel in VD gives a playback speed of 32 kHz. DV should be either 32 or 48 kHz, but 48 was too fast. By experimenting with AssumeSampleRate() I found out the correct rate is 44.1 kHz. That's the first weird thing.

Now here's the REALLY weird thing.

WITHOUT using AssumeSampleRate(), if I play it from the beginning it starts out in sync, but because the audio plays too slow, it quickly goes out of sync. If I stop it and resume playing part way, the audio again starts out in sync! Think about this. If I play the video from the beginning and stop it at frame 100, it is playing the audio that *should* have been with (roughly) frame 72. If I click "stop" and "play" from exactly the same position, it starts playing video and audio both from frame 100! (though by the time it gets to frame 200, the audio is only up to frame 172).

What seems to be happening is, when seeking, the offset into the audio data is calculated using 44.1 kHz, but when playing, it plays at 32 kHz. Somehow there are two different rates for the same audio data!

OK, I thought. I added AssumeSampleRate(44100) to the script.
Now the video would stay in sync if played from the start, BUT if I seek using VD and resume playing from the middle, the audio goes out of sync immediately. I think this is because AssumeSampleRate() has only multiplied the audio rate by a scalar... it now plays at 44.1 kHz, but seeks at 44.1*(44.1/32)=60.7 kHz!!

Anyone know how I can fix this? I want to transcode it using AviSynth.
Remember, this same AVI plays perfectly in ZoomPlayer and WMP (plays and seeks with no loss of sync).
I already recaptured the tape as Type 2 AVI, but that didn't work (no sound at all).

Thanks in advance,
--rling :confused:

Blue_MiSfit
29th May 2007, 01:09
What about using AviSource instead of DirectShowSource?
~MiSfit

rling
5th June 2007, 04:35
What about using AviSource instead of DirectShowSource?
~MiSfit

That made no difference. But I have verified that I really have recorded 44.1 kHz sound onto the DV tape. The tape was recorded with edited video encoded with MainConcept DV codec. Somehow when editing down the DV I transcoded the audio to 44.1 kHz without noticing, and MainConcept didn't warn about the nonstandard rate. Nor did the camcorder I used to record which happily played back the tape, although it showed it as 32 kHz in the viewfinder.

It seems like DVIO.EXE can't re-import the tape as a type 2 DV AVI - the sound goes away. It can re-import as type 1, but then a lot of codecs have trouble with the nonstandard rate. As I said the type 1 played back fine in WMP and ZoomPlayer but not in Avisynth or VirtualDub no matter what I did with it.

I solved this by using WinDV instead of DVIO to import the tape, this was able to import a good type 2 which works fine in Avisynth and VirtualDub. So I'll use WinDV from now on.

I also installed the Cedocida DV codec, this might have been part of the fix but I don't think so. If using WinDV doesn't work, try this.

rling
5th June 2007, 04:39
Actually I just read on Wikipedia that the DV spec does allow 44.1 kHz, but that it is hardly ever used which probably means it is poorly supported. 32 kHz and 48 kHz are the main ones.

So take care if you encode DV and record it back to tape... if you need to if you accidentally record an unusual audio sample rate you might have a hard time getting it back off the tape again !! :eek: