Answers.Body: <p>This can be done using the filter <a href="https://forum.doom9.org/showthread.php?t=162266&amp;highlight=ClipClop" rel="nofollow noreferrer">ClipClop</a>. Here is an <strong>example script</strong> from the docs of the filter:</p>
  
  <pre><code>Avisource("D:\avs\test.avi")
  ORG=Last
  
  V1 = FFT3DFilter(Plane=0,Sigma=1.6)     # Light Luma
  V2 = FFT3DFilter(Plane=0,Sigma=2.0)     # Med   Luma
  V3 = FFT3DFilter(Plane=0,Sigma=4.0)     # High  Luma
  V4 = FFT3DFilter(Plane=3,Sigma=1.6)     # Light Chroma
  V5 = FFT3DFilter(Plane=3,Sigma=2.0)     # Med   Chroma
  V6 = FFT3DFilter(Plane=3,Sigma=4.0)     # High  Chroma
  V7 = FFT3DFilter(Plane=4,Sigma=1.6)     # Light Luma+Chroma
  V8 = FFT3DFilter(Plane=4,Sigma=2.0)     # Med   Luma+Chroma
  V9 = FFT3DFilter(Plane=4,Sigma=4.0)     # High  Luma+Chroma
  V10= FlipHorizontal()                   # Flip-H
  V11= FlipVertical()                     # Flip-V
  V12= Invert()                           # Invert
  
  NickNames ="""  # Psuedonyms for clips (clip index number)
      L0   = 1    # Light Luma
      L1   = 2    # Med   Luma
      L2   = 3    # High  Luma
      C0   = 4    # Light Chroma
      C1   = 5    # Med   Chroma
      C2   = 6    # High  Chroma
      LC0  = 7    # Light Luma + Chroma
      LC1  = 8    # Med   Luma + Chroma
      LC2  = 9    # High  Luma + Chroma
      FH   = 10   # Flip-H
      FV   = 11   # Flip-V
      INV  = 12   # Invert
  """
  
  SCMD="""          # Clip editing commands in string, can also use commands in file
      C0  0,99      # Light Chroma frames @ 0 -&gt; 99
      L0  100,-200  # Light Luma frames @ 100, 200 frames ie frames 100-&gt;299
      INV 300,399   # Invert 300-&gt;399
      L0  400,499   # Light Luma frames 400-&gt;499
      FH  500,599   # Flip-H 500-&gt;599
      LC2 600,699   # High Luma + Chroma
      C1  800       # Med Chroma, Single frame
      1   900,999   # Light Luma, We used the clip number instead of a NickName
      FV  1000,1099 # Flip-V
      LC1 2000,0    # Med   Luma + Chroma, 2000 -&gt; lastframe
  """
  
  SHOW=True
  
  ClipClop(ORG,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,scmd=SCMD,nickname=NickNames,show=SHOW)
  </code></pre>
  
  <p>How to do it:</p>
  
  <ol>
  <li>You define different versions of the original clip (<code>V1</code> - <code>V12</code>) using your desired filters.</li>
  <li>You can assign nicknames to those versions.</li>
  <li>You define the segments using the <code>scmd</code> parameter of the filter. Here you can define which frame ranges of the original clip should be replaced by which nicknamed versions.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-27T15:44:13.553Z
Answers.LastActivityDate: 2018-10-27T15:44:13.553Z
Answers.UserDisplayName: Krisztián Balla
Answers.Body: <p>You definitely need <a href="http://avslib.sourceforge.net/" rel="nofollow noreferrer">AVSLib</a> (the extension library for AviSynth — very old but very stable library) with very nice documentation, as you may see by clicking my link.</p>
  
  <p>It has many-many useful features — in your case <em>arrays of clips</em> and functions for manipulating them, of course.</p>
  
  <p>(Downloaded <code>.zip</code> file / <code>.exe</code> installer includes the same HTML documentation in an off-line form.)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-21T23:00:04.367Z
Answers.LastActivityDate: 2019-12-21T23:05:19.793Z
Answers.LastEditDate: 2019-12-21T23:05:19.793Z
Answers.UserDisplayName: MarianD
Answers.Body: <p>Now, after some period of time, there are versions of AviSynth+ <strong>3.6</strong>+, which <strong>support arrays</strong>.</p>
  <p>So you may still use the script from your answer, although with some fixes, mostly in your syntax (you used C/C++ syntax ;-)):</p>
  <pre><code>original = Last
  segments = [ \
      [ 0,  100, &quot;high&quot;], \
      [101, 200, &quot;low&quot; ]  \
  ]
  clip = original.Trim(0, -1)             # a &quot;base&quot; 1-frame clip - see note 1
  for (i = 0, segments.ArraySize-1, 1)    # syntax different from C/C++ - see notes 2, 3 
  {
      clip = clip + original.Trim(segments[i,0], segments[i,1]).RemoveNoise(segments[i,2])
  }
  clip = clip.Trim(1, 0)                  # remove a “base” 1-frame clip 
  </code></pre>
  <hr />
  <p><em>Notes:</em></p>
  <ol>
  <li><p>Instead of your <code>BlankClip()</code><br />
  (which is a pitch-black 10 seconds RGB32 clip, 640×480, 24 fps, 16 bit 44100 Hz mono)<br />
  I &quot;borrowed&quot; the first frame of your original clip as a &quot;base&quot; clip:</p>
  <pre><code>clip = original.Trim(0, -1)
  </code></pre>
  <p>(0-frame clips are not allowed.)</p>
  </li>
  <li><p>Syntax for <code>for</code> block is different from C/C++:</p>
  <ul>
  <li><strong>commas</strong> (<code>,</code>) instead of semicolons (<code>;</code>),</li>
  <li>the 2<sup>nd</sup> “parameter” is not a condition, but simply the <strong>upper limit</strong>,</li>
  <li>the 3<sup>nd</sup> “parameter” is not a repeatedly computed expression, but simply the <strong>step</strong>.<br />
  (It may be omitted – the default step is 1).</li>
  </ul>
  </li>
  <li><p>The correct name of the function is <em>not</em> <code>Size()</code>, but <strong><code>ArraySize()</code></strong>:</p>
  <pre><code>segments.ArraySize               # or segments.ArraySize()
  </code></pre>
  </li>
  <li><p>There is no <code>+=</code> assignment operator in AviSynth, so I changed your</p>
  <pre><code>clip += original.Trim(...)...
  </code></pre>
  <p>to</p>
  <pre><code>clip = clip + original.Trim(...)...
  </code></pre>
  </li>
  <li><p>Instead of using indexes in the form <code>segments[i][k]</code> (which is OK), I used a shorter form <code>segments[i,k]</code>.</p>
  </li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-03T04:36:23.557Z
Answers.LastActivityDate: 2023-09-03T14:35:17.903Z
Answers.LastEditDate: 2023-09-03T14:35:17.903Z
Answers.UserDisplayName: MarianD
Body: <p>I have a video file and I want to post-process it using AviSynth. Different parts of the movie require different filters to be used (noise reduction etc.). How can one use different filters for different parts of the input video?</p>
  <p>What I once did is to trim the video into segments, apply different filters on them and then concatenate the segments back together. Something like this:</p>
  <pre><code>a = clip.Trim(0, 100).RemoveNoise(&quot;high&quot;)
  b = clip.Trim(101, 200).RemoveNoise(&quot;low&quot;)
  clip = a + b
  </code></pre>
  <p>Is there any other way to do this? I am asking, because the more segments you create, the more cumbersome the script becomes.</p>
  <p>I've read that AviSynth+ supports arrays. So one might create an array with the frame indices and then build the final clip using a loop. Something like this:</p>
  <pre><code>original = last
  segments = [ \
      [ 0,  100, &quot;high&quot;], \
      [101, 200, &quot;low&quot;] \
  ]
  clip = BlankClip()
  for (i = 0; i &lt; segments.Size; ++i)
  {
      clip += original.Trim(segments[i][0], segments[i][1]).RemoveNoise(segments[i][2])
  }
  </code></pre>
  <p>This way one could create an array, holding the segments. But, it seems to me that despite <a href="https://forum.doom9.org/showthread.php?p=1785253#post1785253" rel="nofollow noreferrer">this post here</a>, AviSynth+ does not support arrays at the moment.</p>
  
Tags: <filter>
Title: How to apply different filters to different parts of a video using AviSynth?
UserDisplayName: Krisztián Balla
ThreadText: # How to apply different filters to different parts of a video using AviSynth?
  
  (Asked by: username_0 on 2018-10-27)
  
  I have a video file and I want to post-process it using AviSynth. Different parts of the movie require different filters to be used (noise reduction etc.). How can one use different filters for different parts of the input video?
  
  What I once did is to trim the video into segments, apply different filters on them and then concatenate the segments back together. Something like this:
  
  ```
  a = clip.Trim(0, 100).RemoveNoise("high")
  b = clip.Trim(101, 200).RemoveNoise("low")
  clip = a + b
  
  ```
  
  Is there any other way to do this? I am asking, because the more segments you create, the more cumbersome the script becomes.
  
  I've read that AviSynth+ supports arrays. So one might create an array with the frame indices and then build the final clip using a loop. Something like this:
  
  ```
  original = last
  segments = [ \
      [ 0,  100, "high"], \
      [101, 200, "low"] \
  ]
  clip = BlankClip()
  for (i = 0; i < segments.Size; ++i)
  {
      clip += original.Trim(segments[i][0], segments[i][1]).RemoveNoise(segments[i][2])
  }
  
  ```
  
  This way one could create an array, holding the segments. But, it seems to me that despite [this post here](https://forum.doom9.org/showthread.php?p=1785253#post1785253), AviSynth+ does not support arrays at the moment.
  
  **Tags:** filter
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2018-10-27. Score: 1
  
  This can be done using the filter [ClipClop](https://forum.doom9.org/showthread.php?t=162266&highlight=ClipClop). Here is an **example script** from the docs of the filter:
  
  ```
  Avisource("D:\avs\test.avi")
  ORG=Last
  
  V1 = FFT3DFilter(Plane=0,Sigma=1.6)     # Light Luma
  V2 = FFT3DFilter(Plane=0,Sigma=2.0)     # Med   Luma
  V3 = FFT3DFilter(Plane=0,Sigma=4.0)     # High  Luma
  V4 = FFT3DFilter(Plane=3,Sigma=1.6)     # Light Chroma
  V5 = FFT3DFilter(Plane=3,Sigma=2.0)     # Med   Chroma
  V6 = FFT3DFilter(Plane=3,Sigma=4.0)     # High  Chroma
  V7 = FFT3DFilter(Plane=4,Sigma=1.6)     # Light Luma+Chroma
  V8 = FFT3DFilter(Plane=4,Sigma=2.0)     # Med   Luma+Chroma
  V9 = FFT3DFilter(Plane=4,Sigma=4.0)     # High  Luma+Chroma
  V10= FlipHorizontal()                   # Flip-H
  V11= FlipVertical()                     # Flip-V
  V12= Invert()                           # Invert
  
  NickNames ="""  # Psuedonyms for clips (clip index number)
      L0   = 1    # Light Luma
      L1   = 2    # Med   Luma
      L2   = 3    # High  Luma
      C0   = 4    # Light Chroma
      C1   = 5    # Med   Chroma
      C2   = 6    # High  Chroma
      LC0  = 7    # Light Luma + Chroma
      LC1  = 8    # Med   Luma + Chroma
      LC2  = 9    # High  Luma + Chroma
      FH   = 10   # Flip-H
      FV   = 11   # Flip-V
      INV  = 12   # Invert
  """
  
  SCMD="""          # Clip editing commands in string, can also use commands in file
      C0  0,99      # Light Chroma frames @ 0 -> 99
      L0  100,-200  # Light Luma frames @ 100, 200 frames ie frames 100->299
      INV 300,399   # Invert 300->399
      L0  400,499   # Light Luma frames 400->499
      FH  500,599   # Flip-H 500->599
      LC2 600,699   # High Luma + Chroma
      C1  800       # Med Chroma, Single frame
      1   900,999   # Light Luma, We used the clip number instead of a NickName
      FV  1000,1099 # Flip-V
      LC1 2000,0    # Med   Luma + Chroma, 2000 -> lastframe
  """
  
  SHOW=True
  
  ClipClop(ORG,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,scmd=SCMD,nickname=NickNames,show=SHOW)
  
  ```
  
  How to do it:
  
  1. You define different versions of the original clip (`V1` - `V12`) using your desired filters.
  2. You can assign nicknames to those versions.
  3. You define the segments using the `scmd` parameter of the filter. Here you can define which frame ranges of the original clip should be replaced by which nicknamed versions.
  
  
  ---
  
  ### Answer by username_1 on 2019-12-21. Score: 0
  
  You definitely need [AVSLib](http://avslib.sourceforge.net/) (the extension library for AviSynth — very old but very stable library) with very nice documentation, as you may see by clicking my link.
  
  It has many-many useful features — in your case *arrays of clips* and functions for manipulating them, of course.
  
  (Downloaded `.zip` file / `.exe` installer includes the same HTML documentation in an off-line form.)
  
  
  ---
  
  ### Answer by username_1 on 2023-09-03. Score: 0
  
  Now, after some period of time, there are versions of AviSynth+ **3.6**+, which **support arrays**.
  
  So you may still use the script from your answer, although with some fixes, mostly in your syntax (you used C/C++ syntax ;-)):
  
  ```
  original = Last
  segments = [ \
      [ 0,  100, "high"], \
      [101, 200, "low" ]  \
  ]
  clip = original.Trim(0, -1)             # a "base" 1-frame clip - see note 1
  for (i = 0, segments.ArraySize-1, 1)    # syntax different from C/C++ - see notes 2, 3 
  {
      clip = clip + original.Trim(segments[i,0], segments[i,1]).RemoveNoise(segments[i,2])
  }
  clip = clip.Trim(1, 0)                  # remove a “base” 1-frame clip 
  
  ```
  
  ---
  
  *Notes:*
  
  1. Instead of your `BlankClip()`  
     (which is a pitch-black 10 seconds RGB32 clip, 640×480, 24 fps, 16 bit 44100 Hz mono)  
     I "borrowed" the first frame of your original clip as a "base" clip:
  
     ```
     clip = original.Trim(0, -1)
  
     ```
  
     (0-frame clips are not allowed.)
  2. Syntax for `for` block is different from C/C++:
  
     * **commas** (`,`) instead of semicolons (`;`),
     * the 2nd “parameter” is not a condition, but simply the **upper limit**,
     * the 3nd “parameter” is not a repeatedly computed expression, but simply the **step**.  
       (It may be omitted – the default step is 1).
  3. The correct name of the function is *not* `Size()`, but **`ArraySize()`**:
  
     ```
     segments.ArraySize               # or segments.ArraySize()
  
     ```
  4. There is no `+=` assignment operator in AviSynth, so I changed your
  
     ```
     clip += original.Trim(...)...
  
     ```
  
     to
  
     ```
     clip = clip + original.Trim(...)...
  
     ```
  5. Instead of using indexes in the form `segments[i][k]` (which is OK), I used a shorter form `segments[i,k]`.
  
  
  ---
  
  