VideoHelp Forum




+ Reply to Thread
Page 1 of 2
1 2 LastLast
Results 1 to 30 of 55
  1. Anonymous344
    Guest
    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.
    Last edited by Anonymous344; 6th Apr 2013 at 16:19.
    Quote Quote  
  2. I wasn't sure of the difference between the two terms, crossfade and dissolve, so I looked up crossfade:
    1. to fade out (an image or sound) while simultaneously fading in a different image or sound.
    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.
    Quote Quote  
  3. Anonymous344
    Guest
    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.
    Quote Quote  
  4. 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
    Quote Quote  
  5. Anonymous344
    Guest
    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.
    Quote Quote  
  6. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    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
    Quote Quote  
  7. Anonymous344
    Guest
    Wow! That's quite a wish list!

    I knew of Sox, but had thought of it only in terms of an audio converter rather than something that could be used for audio when scripting.
    Quote Quote  
  8. Member Benjy's Avatar
    Join Date
    Oct 2009
    Location
    Canada
    Search Comp PM
    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
    Quote Quote  
  9. Anonymous344
    Guest
    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.
    Quote Quote  
  10. Member Benjy's Avatar
    Join Date
    Oct 2009
    Location
    Canada
    Search Comp PM
    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
    Quote Quote  
  11. Anonymous344
    Guest
    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)
    Quote Quote  
  12. Seems like you should be able to use Animate() and Pow() and MixAudio()...
    Quote Quote  
  13. Anonymous344
    Guest
    Thanks, jagabo. Unfortunately, I wouldn't know where to start. I've read the entries for those in the Avisynth wiki but understand only MixAudio(), which seems straightforward enough.
    Quote Quote  
  14. I'm working on it.
    Quote Quote  
  15. Anonymous344
    Guest
    Wow! I'm very grateful.
    Quote Quote  
  16. 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)
    ColorBars() creates a test video with a test tone on the left channel, silence on the right channel, for the first 30 frames. I create a second video from that with reversed audio channels. Then use Animate() to call NonLinearAudioCrossfade(). The last argument to that function is the power curve. In this example it's 1.0, linear, but you can change it to other values to get slower or faster non-linear crossfades. If you open this script in VirtualDub and enable the audio display you'll see the problems.
    Quote Quote  
  17. Anonymous344
    Guest
    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()
    Quote Quote  
  18. 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.
    Quote Quote  
  19. Anonymous344
    Guest
    Thanks for the suggestion, but making even one crossfade is starting to sound laborious. It seemed as if Avisynth had all the components for making non-linear crossfades, but the way that MixAudio() processes audio is a major stumbling block.
    Quote Quote  
  20. Originally Posted by Jeff B View Post
    making even one crossfade is starting to sound laborious.
    Only once. After the function is written it will be simple to call it. But I'm not having much luck.
    Quote Quote  
  21. Anonymous344
    Guest
    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.
    Quote Quote  
  22. Dissolve() doesn't let you specify the mix of the two audio channels. The Fade Functions have the same issue.
    Quote Quote  
  23. Anonymous344
    Guest
    Oh, yeah. I didn't think of that.
    Quote Quote  
  24. You can get a faster initial fade and longer tail using multiple fade calls.
    Quote Quote  
  25. Anonymous344
    Guest
    That's another thing I didn't think of. Good idea! I'll give it a try.
    Quote Quote  
  26. And I think you should be able to get the opposite by reversing the section, repeated fade calls, the reversing again.
    Quote Quote  
  27. Anonymous344
    Guest
    Could one use repeated calls to Dissolve() rather than Fade() or would that not work?
    Quote Quote  
  28. 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)
    Not great.
    Quote Quote  
  29. Anonymous344
    Guest
    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.
    Quote Quote  
  30. 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:
    Click image for larger version

Name:	Nonlinear.png
Views:	349
Size:	12.2 KB
ID:	20383

    Dissolve(FadeOut(v1,16).FadeOut(16).FadeOut(16), FadeIn(v2,16).FadeIn(16).FadeIn(16), 22):
    Click image for larger version

Name:	dissolve+fades.png
Views:	377
Size:	12.7 KB
ID:	20384

    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!