0

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:

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 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?

1 Answer 1

2
function SegmentedDissolve(string base, int first_val, int last_val, string format, int dissolve_length ){
    filename = base + string(first_val, format) + ".MOV"
    result = FFMS2(filename)
    return (first_val < last_val) \
        ? Dissolve(result, SegmentedDissolve(base, first_val+1, last_val, format, dissolve_length), dissolve_length) \
        : result
}

SegmentedDissolve("F:\_DSC", 1, 9, "%03.0f", 50).Trim(3600, yyy).FadeIn(100).FadeOut(100)

You would need to figure out what value yyy needs to be for the concatenated clip. If the first clip needs to be trimmed on both sides, then the first clip should not be included in the function (start first_val at 2), and instead get loaded, processed, and concatenated manually.

As a note, the FFMS2 function also loads up any audio found in the specified clip, so you do not need to dub it unless you are doing processing on it first.

1
  • I lost access to AviSynth on Windows and could not install it on Azure. I may try this code on macOS now that AviSynth is compatible.
    – emonigma
    Commented Sep 27, 2020 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.