Log in

View Full Version : audio format conversion and VDub crashes


Wilbert
1st November 2002, 11:18
We are looking at format conversions (including the audio part). The main problem is that VDub keep crashing when applying those conversions. Consider the following four scripts (only for progressive PAL to progressive NTSC conversions and back):

video = AviSource("F:\Nieuw6\raw.avi", false).ConvertToYUY2.Telecide
audio = WavSource("F:\Nieuw6\raw.avi")

function NTSC2PAL(clip video, clip "audio")
{
clip1 = video.AssumeFPS(30)
clip2 = clip1.Decimate(6)
audio1 = (IsClip(audio)==true) ? audio.ResampleAudio(round(audio.Audiorate * 29.976/30.)).AssumeSampleRate(audio.Audiorate) : clip2
return (IsClip(audio)==true) ? AudioDub(clip2, audio1) : clip2
}

function PAL2NTSC(clip video, clip "audio")
{
clip1 = video.selectEvery(1, 0, 0)
clip2 = clip1.Decimate(5).Decimate(4)
clip3 = clip2.AssumeFPS(29.97)
audio1 = (IsClip(audio)==true) ? audio.ResampleAudio(round(audio.Audiorate * 30/29.97)).AssumeSampleRate(audio.Audiorate) : clip3
return (IsClip(audio)==true) ? AudioDub(clip3, audio1) : clip3
}

video = Audio(video, audio)

function NTSC2PAL2(clip clip, int "a")
{
Assert( (a==0)||(a==1), "Must the audio be converted or not?")
AudioSync = (a==1) ? true : false
clip1 = clip.AssumeFPS(30, sync_audio=AudioSync)
clip2 = clip1.Decimate(6)
return (a==1) ? clip2.ResampleAudio(clip.Audiorate) : clip2
}

function PAL2NTSC2(clip clip, int "a")
{
Assert( (a==0)||(a==1), "Must the audio be converted or not?")
clip1 = clip.selectEvery(1, 0, 0)
clip2 = clip1.Decimate(5).Decimate(4)
AudioSync = (a==1) ? true : false
clip3 = clip2.AssumeFPS(29.97, sync_audio=AudioSync)
return (a==1) ? clip3.ResampleAudio(clip.AudioRate) : clip3
}

First questions: the functions PAL2NTSC and PAL2NTSC2 seem to give similar results (looking especially at the audio). Is that true, is the quality the same?

Second question: Vdub keeps crashing on PAL2NTSC (video: fast recompress, audio: full proc. mode) on the last frame. Is the problem that ResampleAudio and AssumeSampleRate only accepts integer values (so the lengths of the video and audio are not exacty equal anymore), or are there other problems?

Third question: PAL2NTSC2 works fine, but VDub keeps crashing when applying NTSC2PAL after you applied PAL2NTSC (somewhere in the middle). Of course you should get the original clip back. Why is that?

Alestrix
1st November 2002, 12:39
It doesn't really refer to your question, but it's something else I noticed in your PAL2NTSC code:

Originally posted by Wilbert
clip1 = video.selectEvery(1, 0, 0)
clip2 = clip1.Decimate(5).Decimate(4)

Deleted a lot of lines I wrote here because I didn't remember Decimate is somewhat "smart" when choosing which frame to delete
But anyway, wouldn't

SelectEvery(5, 0, 1, 2, 3, 4, 4)

be a little bit faster because no check for which frames are duplicates has to be done by Decimate?
Why the VDub crash I actually have no idea, sorry.

- Alex

Edit: actually your code should create something like SelectEvery(5, 0, 1, 2, 2, 3, 4)