VideoHelp Forum
+ Reply to Thread
Results 1 to 8 of 8
Thread
  1. I am new to AviSynth+. I am concatenating 9 clips, trimming the first and last, fading in the first and fading out the last, and cross-dissolving between clips. This code works:

    Code:
    audio=ffaudiosource("F:\_DSC001.MOV")
    video=FFMS2("F:\_DSC001.MOV")
    start=AudioDub(audio, video)
    clip1=Trim(start, 3600, 30000)
    
    audio=ffaudiosource("F:\_DSC002.MOV")
    video=FFMS2("F:\_DSC002.MOV")
    clip2=AudioDub(audio, video)
    
    ... same for clips 3-8 ...
    
    audio=ffaudiosource("F:\_DSC009.MOV")
    video=FFMS2("F:\_DSC009.MOV")
    clip9=Trim(AudioDub(audio, video), 0, 22575)
    
    FadeIn(clip1, 100)
    Dissolve(last, clip2, 50)
    Dissolve(last, clip3, 50)
    Dissolve(last, clip4, 50)
    Dissolve(last, clip5, 50)
    Dissolve(last, clip6, 50)
    Dissolve(last, clip7, 50)
    Dissolve(last, clip8, 50)
    Dissolve(last, clip9, 50)
    FadeOut(last, 100)
    It's quite verbose and repetitive. I have around 20 other shows to do this for and I wonder if some pre-processor script can take some of these parameters and arguments and produce the above AviSynth+ script.

    Does such a pre-processor exist, or could the AviSynth+ script be optimized or improved?
    Quote Quote  
  2. ffms2 can include the audio so there's no reason to use ffaudiosource and audiodub. So you can replace this:

    Code:
    audio=ffaudiosource("F:\_DSC001.MOV")
    video=FFMS2("F:\_DSC001.MOV")
    start=AudioDub(audio, video)
    clip1=Trim(start, 3600, 30000)
    with:

    Code:
    clip1=FFMS2("F:\_DSC001.MOV", atrack=-1).Trim(3600, 30000)
    You can do that for each of your sources:

    Code:
    clip1=FFMS2("F:\_DSC001.MOV", atrack=-1).Trim(3600, 30000)
    clip2=FFMS2("F:\_DSC002.MOV", atrack=-1)
    ... same for clips 3-8 ...
    clip9=FFMS2("F:\_DSC009.MOV", atrack=-1).Trim(0, 22575)
    
    FadeIn(clip1, 100)
    Dissolve(last, clip2, 50)
    Dissolve(last, clip3, 50)
    Dissolve(last, clip4, 50)
    Dissolve(last, clip5, 50)
    Dissolve(last, clip6, 50)
    Dissolve(last, clip7, 50)
    Dissolve(last, clip8, 50)
    Dissolve(last, clip9, 50)
    FadeOut(last, 100)
    Quote Quote  
  3. Thanks! That makes it significantly simpler already. If anyone else can find ways to shorten it, I'm very interested. Otherwise I'll post here a little Python script that produces such an AVS script from a directory listing.
    Quote Quote  
  4. You should also know that both your FadeIn and FadeOut lines add a frame. Maybe it's not important in this case
    Quote Quote  
  5. Yes, use FadeIn0() and FadeOut0() to avoid the additional frame.
    Quote Quote  
  6. You could also create a function that opens and appends each clip with a crossfade:

    Code:
    function AppendWithCF(clip v, string name, int first, int last, int crossfade)
    {
       Dissolve(v, FFMS2(name, atrack=-1).Trim(first, last), crossfade)
    }

    Then your script would look something like:

    Code:
    function AppendWithCF(clip v, string name, int first, int last, int crossfade)
    {
       Dissolve(v, FFMS2(name, atrack=-1).Trim(first, last), crossfade)
    }
    
    FFMS2("F:\_DSC001.MOV", atrack=-1).Trim(3600, 30000)
    AppendWithCF("F:\_DSC002.MOV", 0, 0, 50)
    AppendWithCF("F:\_DSC003.MOV", 0, 0, 50)
    AppendWithCF("F:\_DSC004.MOV", 0, 0, 50)
    AppendWithCF("F:\_DSC005.MOV", 0, 0, 50)
    AppendWithCF("F:\_DSC006.MOV", 0, 0, 50)
    AppendWithCF("F:\_DSC007.MOV", 0, 0, 50)
    AppendWithCF("F:\_DSC008.MOV", 0, 0, 50)
    AppendWithCF("F:\_DSC009.MOV"0, 22575, 50)
    FadeIn0(100)
    FadeOut0(100)
    Quote Quote  
  7. Yes, that's what I was looking for. Thanks for the hint which does not trim and keeps the code simple:

    Code:
    clip.Trim(0, 0)
    The function "AppendWithCF" is defined with 5 arguments and the lines using it use 4; should the first argument be "last" throughout?
    Quote Quote  
  8. Originally Posted by miguelmorin View Post
    Yes, that's what I was looking for. Thanks for the hint which does not trim and keeps the code simple:

    Code:
    clip.Trim(0, 0)
    The function "AppendWithCF" is defined with 5 arguments and the lines using it use 4; should the first argument be "last" throughout?
    Yes and no. Pretty much all functions take a video as input and a produce a video as output. Whenever you call a function without specifying a video AviSynth assumes the name "last". And whenever you don't specify a name for the video returned by a function AviSynth assumes the name "last". So a call like

    Code:
    AppendWithCF("F:\_DSC002.MOV", 0, 0, 50)
    is equivalent to:

    Code:
    last = AppendWithCF(last, "F:\_DSC002.MOV", 0, 0, 50)
    A script like:

    Code:
    video = FFMS2("F:\_DSC001.MOV", atrack=-1).Trim(3600, 30000)
    AppendWithCF("F:\_DSC002.MOV", 0, 0, 50)
    will fail because the output of FFMS2() was explicitly named "video" but the call to AppanedWithCF() assumes "last" -- which doesn't exist yet.
    Quote Quote  



Similar Threads

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