Log in

View Full Version : Problem with choppy audio and MixAudio.


StifflerStealth
10th December 2007, 23:12
Hi,

I am trying to mix two audio tracks together so that the audio crossfades while the video does not. I came up with the following function. I will leave my comments in there so you know why I do things that way.

function AudioDissolveEnd(clip c,clip audio,int fadeFrames,float fps)
{
# This function dissolve the audio to the end of a clip.
# Returns a clip of the same length as input clip with new audio at the end.
# No error checking on the fadeFrames value.

# The Frame Range of Clips are 0 - (FC* - 1)
FCClip = FrameCount(c)
FCAudio = FrameCount(audio)

# Cut the main clip so that the last part is the same length as the audio part.
c_part1 = c.Trim(0,FCClip - FCAudio - 1)
c_part2 = c.Trim(FCClip - FCAudio,0)

# Make a copy of clip so that the audio only can be faded.
c_part2_v = c_part2
c_part2_a = c_part2

# Fade the audios: c is fading out and audio is fading in since this is the end of c.
c_part2_a = FadeOut0(c_part2_a,fadeFrames,0,fps)
audio = FadeIn0(audio,fadeFrames,0,fps)

# Remake c_part2
c_part2 = AudioDub(c_part2_v,c_part2_a)

# MixAudio returns the video of the first clip, by doing the AudioDub first, it saves processor, I think.
# At any rate, the audio is coppy if I don't separate it.
c_part2 = MixAudio(c_part2,audio)

return c_part1+c_part2
}

First, I wanted the function to auto-detect the clip's fps and use that value, but I don't know how to do that.

The reason so many things are separate instead of one line is that I have this issue with audio. When I return just c_part2, the fading and mixing of audio works just fine. However, when I return c_part1+c_part2, the audio is really choppy and horrible.

Here is a link to a small part of the mixed audio. It's a wav file, so I kept it small: http://eruonen.serveblog.net/Arc_01.wav

I used vdub to make the encoding. I encoded video to xvid and audio as uncompressed. I just saved the small audio part and no video to make the file small.

I am using AVS v2.5.8 Alpha 2. Is this a bug in this version of AVS? Is this a bug in my script? I am not using any modified version of AVS either. I use Windows Vista, could that be a factor?

My thought is that the encoding is taking place before AVS has had time to render the audio effects. Is this a correct thought? If this is the case, how I slow down the encode to allow time for AVS to catch up?

Thanks.