View Full Version : FadeIn/Out question
Swan
23rd January 2003, 13:17
I am using av Avisynth script in TMPGEnc.
I use the script because I want the video clip to fade in from black and out to black.
I've noticed that with FadeIn and FadeOut, one black frame is added at the end, and at start of the file.
How does this extra frame at the start influence the audio sync?
My script looks like this:
video = AVIFileSource("dirty_vegas.avi")
video = fadein (video, 25)
video = fadeout (video, 25)
audio = WavSource("dirty_vegas.wav")
video = audiodub(video,audio)
video
My source clip is a PAL 25 fps clip.
When opening the avi file VDub, the Preload Skew for the audio is reported as 24000 samples (0.50s). The # frames value for the audio is 6075.
When opening the avs, the preload skew is 0 samples (0.00s) and the # of frames value for the audio is 6086.
Should I input some form of delay value for the audio in my avs, since I am adding a frame at the start of the video with FadeIn?
/Swan
hakko504
23rd January 2003, 13:33
This should produce the correct output, assuming audio and video is synched when they are separate.
video = AVIFileSource("dirty_vegas.avi")
audio = WavSource("dirty_vegas.wav")
video = audiodub(video,audio)
fadeio (video, 25)
Swan
23rd January 2003, 13:57
Thanks, Hakko.
Yes the sync is 100% Ok on audio and video when separated.
Can you please explain the difference between using fadeio (video, 25)
and video = fadein (video, 25) + video = fadeout (video, 25)?
With your script I get:
Preload Skew 0 samples (0.00s) and the # of frames value for the audio is 6088. 6088 is also the number of video keyframes, so these figures match.
With the old script (fadein and fadeout)I get:
Preload skew is 0 samples (0.00s) and the # of frames value for the audio is 6086. Number of video keyframes are 6088.
With the orginal avi file I get:
Preload Skew 24000 samples (0.50s) and the # of frames value for the audio is 6075. The number of video keyframes are 6086. These figures don't match.
This is a DV file, so all frames are keyframes. What is VirtualDub telling me here? And how can I calculate a correct figure in the future, should I want to use fewer or more frames for fades?
I guess I am not understanding what the fade function does. :)
/Swan
hakko504
23rd January 2003, 14:17
First, fadeio(n)is shorthand for fadein(n).fadeout(n) The fade funtion will also fade the sound! Thus if you add the sound before fade then you will be able to maintain sycnh better. In general, when using a filter that changes the length of video you should have audio added before that filter.
Since the fade function will add two frames, one at the start and one at the beginning, this means that your script will start the sound 1 frame too early, so if you want to use that you should add a delay corresponding to 1 frame (40ms=1/25s).
Swan
23rd January 2003, 14:37
First, fadeio(n)is shorthand for fadein(n).fadeout(n) The fade funtion will also fade the sound!
OK. So FadeIO and FadeIO2 fade both the audio and video.
And FadeOut/FadeOut2/FadeIn and FadeIn2 only fades the video (and the "2" indicates that two black frames are added at the end)?
Thus if you add the sound before fade then you will be able to maintain sycnh better.
I understand. And the filter FadeIo does just that? Loads the audio first?
Since the fade function will add two frames, one at the start and one at the beginning, this means that your script will start the sound 1 frame too early, so if you want to use that you should add a delay corresponding to 1 frame (40ms=1/25s).
I think FadeIo will do just fine for me. All I want is that the sync stays 100% correct. If using FadeIo does that, I'm happy.
I am perhaps too tired for this today, so I ask you to please be patient with me. :) Does using FadeIO mean the audio will stay put at the exact same place as in the original file? Or should I also add the 40 ms delay to maintain 100% OK sync, since 1 video frame is added at the start of the video?
/Swan
hakko504
23rd January 2003, 14:45
Originally posted by Swan
OK. So FadeIO and FadeIO2 fade both the audio and video.
And FadeOut/FadeOut2/FadeIn and FadeIn2 only fades the video (and the "2" indicates that two black frames are added at the end)?
No, they will all fade both audio and video.
I understand. And the filter FadeIo does just that? Loads the audio first?No, the audio is loaded and muxed with the video in the AudioSource.Audiodub call. This small modification of your script would be just as good as the one I suggested. Mine is just a much more compact way of writing the same thing.
video = AVIFileSource("dirty_vegas.avi")
audio = WavSource("dirty_vegas.wav")
video = audiodub(video,audio) #This line must come before the fades.
video = fadein (video, 25)
video = fadeout (video, 25)
video
Wilbert
23rd January 2003, 14:47
OK. So FadeIO and FadeIO2 fade both the audio and video.
And FadeOut/FadeOut2/FadeIn and FadeIn2 only fades the video (and the "2" indicates that two black frames are added at the end)?
No, all six of them fade both video and audio. But in your script (which is the same as the following):
video = AVIFileSource("dirty_vegas.avi")
video = fadeio(video, 25)
audio = WavSource("dirty_vegas.wav")
audiodub(video,audio)
you apply fade to the video only. What Hakko says is that
1) you should apply fade to your video and your audio, thus:
video = AVIFileSource("dirty_vegas.avi")
audio = WavSource("dirty_vegas.wav")
clip = audiodub(video,audio)
fadeio(clip, 25)
2) or apply fade to your video, add a delay to your audio and dub them together, thus:
video = AVIFileSource("dirty_vegas.avi")
audio = WavSource("dirty_vegas.wav")
video = fadeio(video, 25)
audio = delayaudio(audio, 0.04)
audiodub(video,audio)
Both methods are not exactly the same, like Hakko said in (2) your audio is not faded.
Swan
23rd January 2003, 16:38
:stupid:
LOL!
Thank you!
No, the audio is loaded and muxed with the video in the AudioSource.Audiodub call. This small modification of your script would be just as good as the one I suggested. Mine is just a much
more compact way of writing the same
I finally get it! :)
One thing I still don't understand is how I should interpret what VirtualDub is telling me about my avi-file.
Vdub tells me that the number of video keyframes are 6086.
Under "Audio" I read "Preload skew 24000 samples (0.50s)" and below that "# of frames: 6075".
Is this normal? Should the # of audio frames match the # of video frames?
What is the "preload skew" value? :D
What I have done is opened the avi in Vdub and extracted the wav. Did some work on that and loaded it back in with the video via the avs. Should I put in some form of delay for the audio, based on what VirtualDub says about the preload skew of 0.50 s?
Let's say I use the method where video and audio fades simultaneously (method #1 in Wilbert's post), so we can forget about the 40 ms for a while.
Should I add "delayaudio" in the script because of what Vdub states about the original avi?
/Swan
fisix
25th January 2003, 00:52
hmm.
this might just be useless, but here is how i use fade in and fade out.
i capture to huffy avi (really big file) with the audio
interleaved as a wav (pcm, 16bit stereo), then create
an avs file that has all the filters, including the
fade in and out and trim, that i am going to use during
the encode. i open the avs with virtualdub, then use the
'save as wav' option and get a properly synched, and faded,
wav. then i encode the wav into vbr mp3, and the video into
divx, separately, and mux with nandub for a final divx avi.
you can obvously choose any codecs for either that you want.
-fisix
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.