I do almost all of my video work in Avisynth but am frustrated by the fact that there appear to be no true audio crossfades available. For very simple work at quiet moments in an audio track, I can use the Dissolve() function with satisfactory results, but there are times when simply blending two streams linearly is not enough.
NLEs such as Sony Vegas have a whole range of audio crossfades available, and while taking the audio into an NLE is one solution I really would like to have a similar option available in Avisynth. Is there no way to do this? I have looked for functions for a long time but cannot find any.
+ Reply to Thread
Results 1 to 30 of 55
-
Anonymous344Guest
Last edited by Anonymous344; 6th Apr 2013 at 16:19.
-
I wasn't sure of the difference between the two terms, crossfade and dissolve, so I looked up crossfade:
Which is exactly what the Dissolve command does. So I guess you mean something different when you say there's no true audio crossfade in AviSynth? I don't use Sony Vegas so I don't know what the other kinds of crossfades are. I don't think you mean a simple FadeOut/FadeIn. -
Anonymous344Guest
When Avisynth fades in and out, it does so linearly, according to the definition for Fade(). Maybe the Dissolve() implements a very basic kind of crossfade, but in Vegas when you pull one track over another two curves appear (white and blue), and these can be made to take on different shapes. If you look at this video here, the author brings up the options for different curves at about 0:30. He is just fading out, so you can see only the blue curve, but if two audio tracks are overlapping, the overlapping curves can be made to take on different shapes.
I call this a true crossfade because it blends the outgoing and incoming audio far more smoothly than Dissolve() does, and because I don't know how else to distinguish it from what Avisynth does. Obviously this sort of thing is more difficult to do in a script, and I'm not expecting miracles, but I wondered if there is some way of making Avisynth do, or at least approximate, what Vegas does. -
So you want something besides straight linear dissolves. I think you're asking too much from AviSynth. I do a lot of audio work myself in Audacity (haven't any need even to dissolve audio) and add it back into the video later on. But maybe some others have ideas.
Sorry, Jeff, but I'm no help at all.
Tom -
Anonymous344Guest
That's okay, Tom. I wasn't expecting someone to pull a rabbit out of his hat, but if you never ask, you never know what you might have received. I've looked for this sort of thing for a long time, and I don't think it's possible with Avisynth. It would just make things easier for me if it were.
EDIT: I have wondered about the MixAudio() function, but it's usually used for different things, such as downmixing. -
Audio features in AVISynth are one of its weakest areas. Many people who script use Sox instead. Me, I have had my own templates & macros that I've used in ProTools (doesn't come that way - one has to use 3rd party tools to "extend" it), that often gets the job done just as quickly (if not sooner).
Or I use batch features in Vegas or Audition, etc.
Would be very nice if Audio features were extended in AVISynth, but there are lots of areas I want to see AVISynth expanded: 3D (esp. multi-stream dual-muxed), HDR, network "render farm" type support, etc.
Scott -
I know lot of softs that are doing crossfading in playing, But I need a soft to make such crossfading to be recorded. For instance I wanna split a song and the end to be gradually decreased or when I'm muxing 2 songs, the passing from one to the other to be gradual
-
Anonymous344Guest
If by "softs" you mean "software" and by "muxing" you mean "mixing", I would look at a Sony's website and find a product to suit your needs e.g. Sound Forge. This is not really relevant to Avisynth, which I would not use to do what you've asked.
-
Yep, you're right regarding my "terms ". Meantime I found VirtualDJ home edition but I cannot find its crossfading button....Actually I'll limited myself to make just a mixing between 2-3 songs, without Avisynth, but my big problem is still how to apply crossfading at least at the end of last song
-
Anonymous344Guest
I stumbled across an old Doom9 thread that might be of use here. This is the script from IanB's last post in the thread. While I believe I understand what is happening in the script, I don't understand the role of FrameCount(), nor can I find documentation on it in the Avisynth wiki.
Moreover, the script uses MixAudio(), which I suspected might help with crossfades. I don't understand how the values used are derived though. Maybe they are only examples.
Code:Clip1=...Source(...) Clip2=...Source(...) P1=Clip1.Trim(0, 567) P2=Clip1.Trim(568, 0) Fc=FrameCount(P2) P3=Clip2.Trim(0, Fc-1) P4=Clip2.Trim(Fc, 0) V=P1 + P3 + P4 A=P1 + MixAudio(P2, P3, 0.75, 0.666) + P4 AudioDub(V, A)
-
I've run into two problems:
First, the mix percentage steps by frames so I'm getting the volume changing in steps. For example, if the mix goes from 0 to 100 percent over ten frames you get 0, 10, 20, 30... percent. You could probably work around this, but...
Second, audio appears to be processed by MixAudio() in discreet chunks separate from the associated frames. So the steps don't line up with frames, a step can last for several frames, and you get random behavior with random seeks.
So I don't think this technique has any promise. But here's my (dis)proof of concept script:
Code:function NonLinearAudioCrossfade(clip v1, clip v2, float "fnum", float "fcount", float "power") { volume1 = Pow(fnum/fcount, power) MixAudio(v1, v2, volume1) Subtitle(String(fnum)+" "+String(fcount)+" "+String(volume1)) } ColorBars() v1=Trim(0, 29) l_ch = GetChannel(v1, 1) r_ch = GetChannel(v1, 2) stereo = MergeChannels(r_ch, l_ch) v2=AudioDub(v1,stereo) # ie, swap audio channels in v2 Animate(0, 29, "NonLinearAudioCrossFade", v1,v2,0,30,1.0, v1,v2,29,30,1.0)
-
Anonymous344Guest
Jagabo, thanks for trying. Until just now, I didn't realize that Virtualdub had an audio display! I can indeed see the problems. Would using FadeIn() and FadeOut() and/or something like MergeChannels() be possible?
Last edited by Anonymous344; 6th Oct 2013 at 06:22. Reason: corrected MergeAudio() to MergeChannels()
-
Another approach would be to use Trim to cut the crossfade section into single frames and adjust the mix frame by frame using the same POW() function. That would still leave you with stepwise adjustments. You might be able to work around that by temporarily increasing the frame rate with ChangeFPS(), then reducing it back.
-
-
Anonymous344Guest
Jagabo, how about using your function but with Dissolve() instead of MixAudio()? I know it might change the shape of the waveform a little, but it would get round the fact that MixAudio() processes the audio in discrete chunks. That way, there would be no need to mess around with the frame-rate.
-
Dissolve() doesn't let you specify the mix of the two audio channels. The Fade Functions have the same issue.
-
And I think you should be able to get the opposite by reversing the section, repeated fade calls, the reversing again.
-
Anonymous344Guest
Could one use repeated calls to Dissolve() rather than Fade() or would that not work?
-
I came up with this:
Code:function NonlinearDissolve16f(clip v1, clip v2) # 16 frames { Dissolve(v1, v2, 2) v1=Trim(last, 0, v1.FrameCount-1) v2=Trim(last, v1.FrameCount-2,0) Dissolve(v1, v2, 4) v1=Trim(last, 0, v1.FrameCount-1) v2=Trim(last, v1.FrameCount-4,0) Dissolve(v1, v2, 6) v1=Trim(last, 0, v1.FrameCount-1) v2=Trim(last, v1.FrameCount-6,0) Dissolve(v1, v2, 8) v1=Trim(last, 0, v1.FrameCount-1) v2=Trim(last, v1.FrameCount-8,0) Dissolve(v1, v2, 10) v1=Trim(last, 0, v1.FrameCount-1) v2=Trim(last, v1.FrameCount-10,0) Dissolve(v1, v2, 12) v1=Trim(last, 0, v1.FrameCount-1) v2=Trim(last, v1.FrameCount-12,0) Dissolve(v1, v2, 14) v1=Trim(last, 0, v1.FrameCount-1) v2=Trim(last, v1.FrameCount-14,0) Dissolve(v1, v2, 16) } ColorBars().Info() v1=Trim(0, 29) l_ch = GetChannel(v1, 1) r_ch = GetChannel(v1, 2) stereo = MergeChannels(r_ch, l_ch) v2=AudioDub(v1,stereo) # ie, swap audio channels in v2 v2=FlipVertical(v2) NonlinearDissolve16f(v1, v2) # compare to Dissolve(v1,v2,16)
-
Anonymous344Guest
Thanks. I'll give it a go. It might not be great, but if it's better than Dissolve(), it's still an improvement.
(By the way, ignore the PM I sent: I worked out that TDecimate alone is sufficient.)
EDIT: It's not bad! It's funny seeing the video end up upside down. -
I made the second video an upside down version of the first so I could see the effect on the video as well as the audio.
What I don't like is the first clip's audio fades to nearly inaudible before the second clip's audio starts to be heard. So the audio is closer to a fade out of the first clip followed by a fade in of the second clip rather than a concurrent fade out and fade in. And to make longer crossfades you have to extend the script. I'm pretty sure you can't have the function call itself recursively.
You can come pretty close to the same audio output with a simple:
Dissolve(FadeOut(v1,16).FadeOut(16).FadeOut(16), FadeIn(v2,16).FadeIn(16).FadeIn(16), 22)
NonLinearDissolve156:
Dissolve(FadeOut(v1,16).FadeOut(16).FadeOut(16), FadeIn(v2,16).FadeIn(16).FadeIn(16), 22):
The video looks very different though. With the latter the video fades to nearly black then fades back in with the second clip.Last edited by jagabo; 6th Oct 2013 at 17:26.
Similar Threads
-
Avisynth help please.
By Otokonokotron in forum EditingReplies: 7Last Post: 19th Nov 2012, 16:47 -
avisynth
By sportflyer in forum Newbie / General discussionsReplies: 1Last Post: 16th Feb 2010, 04:36 -
Using avisynth
By bsuska in forum Video ConversionReplies: 8Last Post: 16th Jul 2009, 08:32 -
problem with Sony Vegas 4 crossfades
By silvyr in forum EditingReplies: 2Last Post: 27th Mar 2009, 20:46 -
AVIsynth help!
By helper in forum Newbie / General discussionsReplies: 11Last Post: 15th Oct 2008, 03:35