RemapFrames

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (RemapFrames)
(add External links sections and link to RemapFrames_audiomod)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{FilterCat|External_filters|Adjustment_filters|Range_Processing}}
+
{{FilterCat5|External_filters|Plugins|Plugins_x64|Adjustment_filters|Range_Processing}}
 +
{{Filter3
 +
| James D. Lin ([http://www.avisynth.nl/users/stickboy/ stickboy])
 +
| v0.4.1-avs26
 +
|[https://web.archive.org/web/20200523020423if_/https://files.videohelp.com/u/223002/RemapFrames-0.4.1-avs26.zip RemapFrames-0.4.1-avs26.zip]
 +
| Frame Replacement / Range Processing
 +
| [https://www.gnu.org/licenses/gpl-2.0.txt GPLv2]
 +
| 6=[https://forum.doom9.org/showthread.php?p=1644971#post1644971 Doom9 Thread]
 +
}}
  
<div id="header">
+
== Description ==
 
+
An AviSynth plug-in that remaps the frame indices in a clip as specified by an input text file or by an input string.  
= RemapFrames =
+
<br>
 
+
<br>
v0.4.1 (<span class="date">2014-01-16</span>)
+
== Requirements ==
 
+
* [x86] [[AviSynth+]] or [http://sourceforge.net/projects/avisynth2/ AviSynth 2.6.0]
An AviSynth plug-in that remaps the frame indices in a clip as specified by an input text file or by an input string.
+
* [x64] [[AviSynth+]]
 
+
<br>
by James D. Lin ([http://www.avisynth.nl/users/stickboy/ stickboy])
+
* [https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads Microsoft Visual C++ 2015 Redistributable Package (x86 / x64)]
 
+
:<span style="color:red">***</span> <tt>vcredist_x86.exe</tt> is required for <tt>RemapFrames-x86</tt>
'''Download:'''
+
:<span style="color:red">***</span> <tt>vcredist_x64.exe</tt> is required for <tt>RemapFrames-x64</tt>
*[http://ldesoras.free.fr/src/avs/RemapFrames-0.4.1.zip RemapFrames-0.4.1.zip] - for AviSynth 2.5 and greater
+
<br>
*[http://www.iol.ie/~schubert/gas/gas.html RemapFrames-0.4.1-avs26.zip] - for AviSynth 2.6/AviSynth+ (includes 64-bit version). Requires [http://www.microsoft.com/en-us/download/details.aspx?id=51682 Microsoft Visual C++ 2015 Redistributable Package (x86 / x64)]
+
 
+
 
+
</div><div id="content">
+
  
 
== Overview ==
 
== Overview ==
 
<div class="subBody">
 
  
 
<code>RemapFrames</code>, <code>RemapFramesSimple</code>, and <code>ReplaceFramesSimple</code> provide general control over manipulation of frame indices in a clip. They can be used in cases where <code> SelectEvery</code> isn't suitable, such as when the desired frames don't follow a regular pattern.
 
<code>RemapFrames</code>, <code>RemapFramesSimple</code>, and <code>ReplaceFramesSimple</code> provide general control over manipulation of frame indices in a clip. They can be used in cases where <code> SelectEvery</code> isn't suitable, such as when the desired frames don't follow a regular pattern.
Line 30: Line 32:
 
<code>remf</code>, <code>remfs</code> and <code>rfs</code> are shortcuts for <code>RemapFrames</code>, <code>RemapFramesSimple</code> and <code>ReplaceFramesSimple</code> with slight differences. The <var>mappings</var> parameter comes before <var>filename</var> for a more compact "inline" call. These parameters are completely optional; when none of them is specified, an empty string is assumed. And when an empty string is detected, the filter is completely bypassed (no extra memory use). Also, these versions don't check aggressively the frame ranges. If a referenced frame doesn't exist, it's simply ignored or its index is replaced with the closest valid frame index. This allows working on partial ranges of a clip with a unique set of mappings.
 
<code>remf</code>, <code>remfs</code> and <code>rfs</code> are shortcuts for <code>RemapFrames</code>, <code>RemapFramesSimple</code> and <code>ReplaceFramesSimple</code> with slight differences. The <var>mappings</var> parameter comes before <var>filename</var> for a more compact "inline" call. These parameters are completely optional; when none of them is specified, an empty string is assumed. And when an empty string is detected, the filter is completely bypassed (no extra memory use). Also, these versions don't check aggressively the frame ranges. If a referenced frame doesn't exist, it's simply ignored or its index is replaced with the closest valid frame index. This allows working on partial ranges of a clip with a unique set of mappings.
  
</div>
 
  
 
== Syntax ==
 
== Syntax ==
 
<div class="subBody">
 
 
 
   
 
   
 
  RemapFrames(clip <var>baseClip</var>, string "<var>filename</var>", string "<var>mappings</var>", clip "<var>sourceClip</var>")
 
  RemapFrames(clip <var>baseClip</var>, string "<var>filename</var>", string "<var>mappings</var>", clip "<var>sourceClip</var>")
Line 48: Line 46:
 
  rfs_merge (string "<var>s0</var>", string "<var>s1</var>", …, string "<var>s9</var>")
 
  rfs_merge (string "<var>s0</var>", string "<var>s1</var>", …, string "<var>s9</var>")
  
</div>
 
  
 
== RemapFrames ==
 
== RemapFrames ==
  
<div class="subBody">
 
  
 
=== Parameters ===
 
=== Parameters ===
  
<div class="subBody">
 
  
 
{| cellspacing="10"
 
{| cellspacing="10"
Line 75: Line 70:
 
The source clip used to supply the new, remapped frames.<br /> (Default: Same as <var>baseClip</var>.)
 
The source clip used to supply the new, remapped frames.<br /> (Default: Same as <var>baseClip</var>.)
 
|}
 
|}
 
</div>
 
  
 
=== Usage ===
 
=== Usage ===
 
<div class="subBody">
 
  
 
'''Does not affect the audio track.'''
 
'''Does not affect the audio track.'''
Line 140: Line 131:
 
  </nowiki>
 
  </nowiki>
  
</div></div>
+
 
  
 
== RemapFramesSimple ==
 
== RemapFramesSimple ==
Line 180: Line 171:
  
 
</div></div>
 
</div></div>
 +
  
 
== ReplaceFramesSimple ==
 
== ReplaceFramesSimple ==
Line 228: Line 220:
  
 
</div></div>
 
</div></div>
 +
  
 
== rfs_transform ==
 
== rfs_transform ==
Line 294: Line 287:
  
 
</div></div>
 
</div></div>
 +
  
 
== rfs_merge ==
 
== rfs_merge ==
Line 326: Line 320:
  
 
</div></div>
 
</div></div>
 +
  
 
== Adapting Existing Scripts ==
 
== Adapting Existing Scripts ==
Line 396: Line 391:
 
* 0.1.0
 
* 0.1.0
 
** Initial release.
 
** Initial release.
 +
</div>
 +
<br>
 +
== Archived Downloads ==
 +
{| class="wikitable" border="1"; width="600px"
 +
|-
 +
!!width="100px"| Version
 +
!!width="150px"| Download
 +
!!width="150px"| Mirror
 +
|-
 +
!v0.4.1-avs26
 +
|[http://www.dropbox.com/s/6830ri3btc5crfp/RemapFrames-0.4.1-avs26.zip?dl=1 RemapFrames-0.4.1-avs26.zip]
 +
|[https://web.archive.org/web/20200523020423if_/https://files.videohelp.com/u/223002/RemapFrames-0.4.1-avs26.zip RemapFrames-0.4.1-avs26.zip]
 +
|-
 +
!v0.4.1
 +
|[http://ldesoras.free.fr/src/avs/RemapFrames-0.4.1.zip RemapFrames-0.4.1.zip]
 +
|[https://web.archive.org/web/20170617145252/http://ldesoras.free.fr/src/avs/RemapFrames-0.4.1.zip RemapFrames-0.4.1.zip]
 +
|}
 +
* v0.4.1-avs26 modified by {{Author/Chikuzen}}
 +
<br>
  
</div></div><div id="footer">
+
== External Links ==
 +
* [https://github.com/TomArrow/RemapFrames_audiomod GitHub] - RemapFrames_audiomod; this is a modification that also remaps audio. Only works with the "simple" filter.
 +
<br>
 +
<br>
 +
<div id="footer">
  
 
Copyright © 2005 James D. Lin<br /> Some portions copyright © 2000 Andrei Alexandrescu and Petru Marginean.<br /> Some portions written by Charles B. Falconer.<br /> Some portions written by Laurent de Soras.<br />[http://forum.doom9.org/showthread.php?s=&threadid=78004 Thanks to rhombus for the idea].
 
Copyright © 2005 James D. Lin<br /> Some portions copyright © 2000 Andrei Alexandrescu and Petru Marginean.<br /> Some portions written by Charles B. Falconer.<br /> Some portions written by Laurent de Soras.<br />[http://forum.doom9.org/showthread.php?s=&threadid=78004 Thanks to rhombus for the idea].
  
 
</div>
 
</div>
 +
<br>
 +
<br>
 +
-----------------------------------------------
 +
'''Back to [[External_filters#Frame_Replacement/Range_Processing|External Filters]] &larr;'''
 +
-----------------------------------------------

Latest revision as of 22:52, 1 February 2021

Abstract
Author James D. Lin (stickboy)
Version v0.4.1-avs26
Download RemapFrames-0.4.1-avs26.zip
Category Frame Replacement / Range Processing
License GPLv2
Discussion Doom9 Thread

Contents

[edit] Description

An AviSynth plug-in that remaps the frame indices in a clip as specified by an input text file or by an input string.

[edit] Requirements


*** vcredist_x86.exe is required for RemapFrames-x86
*** vcredist_x64.exe is required for RemapFrames-x64


[edit] Overview

RemapFrames, RemapFramesSimple, and ReplaceFramesSimple provide general control over manipulation of frame indices in a clip. They can be used in cases where SelectEvery isn't suitable, such as when the desired frames don't follow a regular pattern.

RemapFrames/RemapFramesSimple/ReplaceFramesSimple also are efficient alternatives to long chains of FreezeFrame, DeleteFrame, or ApplyRange calls.

RemapFramesSimple and ReplaceFramesSimple are less powerful than RemapFrames but use a much simpler, more basic syntax.

remf, remfs and rfs are shortcuts for RemapFrames, RemapFramesSimple and ReplaceFramesSimple with slight differences. The mappings parameter comes before filename for a more compact "inline" call. These parameters are completely optional; when none of them is specified, an empty string is assumed. And when an empty string is detected, the filter is completely bypassed (no extra memory use). Also, these versions don't check aggressively the frame ranges. If a referenced frame doesn't exist, it's simply ignored or its index is replaced with the closest valid frame index. This allows working on partial ranges of a clip with a unique set of mappings.


[edit] Syntax

RemapFrames(clip baseClip, string "filename", string "mappings", clip "sourceClip")
RemapFramesSimple(clip c, string "filename", string "mappings")
ReplaceFramesSimple(clip baseClip, clip sourceClip, string "filename", string "mappings")

remf(clip baseClip, string "mappings", string "filename", clip "sourceClip")
remfs(clip c, string "mappings", string "filename")
rfs(clip baseClip, clip sourceClip, string "mappings", string "filename")

rfs_transform (string mappings, string "op", bool "open", bool "discrete")
rfs_merge (string "s0", string "s1", …, string "s9")


[edit] RemapFrames

[edit] Parameters

baseClip

Frames from sourceClip are mapped into baseClip.

"filename" The name of the text file that specifies the new frame mappings.
"mappings"

Mappings also may be given directly in a string. Overrides frame mappings given by filename.

"sourceClip"

The source clip used to supply the new, remapped frames.
(Default: Same as baseClip.)

[edit] Usage

Does not affect the audio track.

Each line in the text file or in the mappings string must have one of the following forms:

  • a z
    Replaces frame a in baseClip with frame z from sourceClip.
  • [a b] z
    Replaces all frames in the inclusive range a..b of baseClip with frame z from sourceClip.
  • [a b] [y z]
    Replaces all frames in the range a..b of baseClip with frames in the range y..z from the sourceClip. If the input and output ranges do not have equal sizes, frames will be duplicated or dropped evenly from y ..z to match the size of a..b. If y > z, the order of the output frames is reversed.
  • # comment
    A comment. Comments may appear anywhere on a line; all text from the start of the # character to the end of the line is ignored.

Sample data file:


[0 9] [0 4]     # the first ten frames will be 0, 0, 1, 1, 2, 2, 3, 3, 4, 4
10 5            # show frame 5 in frame 10's place
[15 20] 6       # replace frames 15..20 with frame 6
[25 30] [35 40] # replace frames 25..30 with frames 35..40
[50 60] [60 50] # reverse the order of frames 50..60

Within each line, all whitespace is ignored.

By default, all frames are mapped to themselves.

If multiple lines remap the same frame, the last remapping overrides any previous ones.

 # the frames in the generated clip will be
 # 4, 0, 0, 0, 0, 0, 6, 7, ...
 [0 5] 0
 0 3
 0 4
 

The output clip always will have the same number of frames as the input clip. To delete frames, remap the appropriate frames and then call Trim afterward.

 BlankClip(length=100).ShowFrameNumber()
 
 # Replace frames 50..89 with 60..99.  This effectively deletes frames
 # 50..59.
 RemapFrames(mappings="[50 89] [60 99]")
 
 # Trim off the excess.
 Trim(0, 89)
 

To add duplicate frames, call LengthenClip first and then remap the appropriate frames.

 BlankClip(length=100).ShowFrameNumber()
 
 LengthenClip(110)
 
 # Duplicate frame 50 ten times, and delay all the subsequent frames by
 # ten frames.
 RemapFrames(mappings="[50 59] 50
                       [60 109] [50 99]")
 


[edit] RemapFramesSimple

[edit] Parameters

"filename" The name of the text file that specifies the new frame mappings.
"mappings" Mappings alternatively may be given directly in a string. Unlike RemapFrames, mappings and filename cannot be used together.

[edit] Usage

Does not affect the audio track.

RemapFramesSimple takes a text file or a mappings string consisting of a sequence of frame numbers. The number of frame mappings determines the number of frames in the output clip. For example:

 # Generate a clip containing only the first five frames.
 RemapFramesSimple(mappings="0 1 2 3 4")
 
 # Duplicate frame 20 five times.
 RemapFramesSimple(mappings="20 20 20 20 20")
 


[edit] ReplaceFramesSimple

[edit] Parameters

baseClip
sourceClip

Frames from baseClip are replaced by frames from sourceClip.

"filename" The name of the text file that specifies the frames to replace.
"mappings" Replacement frames alternatively may be given directly in a string.

[edit] Usage

Does not affect the audio track.

ReplaceFramesSimple takes a text file or a mappings string consisting of sequences or ranges of frame numbers to replace. For example:

 # Replaces frames 10..20, 25, and 30 from baseClip with the
 # corresponding frames from sourceClip.
ReplaceFramesSimple(baseClip, sourceClip, mappings="[10 20] 25 30")
 # Inverse-telecine a clip and fix individual frames that still show
 # combing.
 c = src.Telecide(...).Decimate(...)
 deinterlaced = c.KernelDeint(...)
 
 # Replace frames 30, 40, 50 with their deinterlaced versions.
 ReplaceFramesSimple(c, deinterlaced, mappings="30 40 50")
 


[edit] rfs_transform

[edit] Parameters

"mappings" A frame mapping string that can be used in ReplaceFramesSimple or rfs.
"op" String containing the operation to perform on the original mappings. Default: "x".
"open"

Indicates if ranges and single frames should be converted to half-open intervals before being tranformed then converted back to closed intervals. This flag is ignored when discrete is set to true. Default: true.

"discrete" Indicates if ranges should be split into individual frames before being transformed, and possibly grouped in ranges afterwards. Default: false.

[edit] Usage

rfs_transform is a helper function transforming a set of mappings for ReplaceFramesSimple using an arithmetic operation. This is useful when one needs to substitute frames after a framerate change or any kind of timeline manipulation.

The operation is noted in Reverse Polish Notation (or Postfix). All calculation are done in double-precision floating point data. The resulting frame is rounded to the nearest (even) integer. The logical operations return 0 or 1 and assume the input is false if exactly equal to 0, true otherwise. Here is a list of the available operators:

  • neg ! round floor ceil
  • - * / mod min max == != > >= < <= && || ^^
  • clip ?

There are three input variables:

  • x: the current frame index being processed,
  • r: indicates if it's the frame is the beginning of a range (0) or the end (1),
  • y: the other range boudary.

Excepted in discrete mode, single frames are considered as a ranges containing one frame. In half-open interval mode, the end of the range is augmented of 1 before the calculation. This ensures that the ranges and their implicit complementary intervals are treated equaly, with more consistency. This is an easy solution to avoid gaps at the range boundaries when the timeline is dilated.

When a range is reverted (time inversion), the function automatically swaps the resulting range boundaries and keep everything consistent.

Frames indexes are truncated if they go below 0, but there is no upper bound check. In half-open mode, the end of the clip is indexed by the frame after the last frame (whose number equals the total number of frames), whereas in closed mode, the end is the last frame (total number of frames minus 1).

Examples:

 # Shifts the mappings 10 frames forward
 rfs_transform ("[100 199] 300 [400 999]", op="x 10  ")
 # result: "[110 209] 310 [410 1009]"
 
 # Dilates the mappings 5 times
 rfs_transform ("[100 199] 300 [400 999]", op="x 5 *")
 # result: "[500 999] [1500 1504] [2000 4999]"
 


[edit] rfs_merge

[edit] Parameters

"s0", …, "s9" Strings that can be used in ReplaceFramesSimple or rfs. Default: undefined.

[edit] Usage

rfs_merge is a helper function merging several mappings for ReplaceFramesSimple together. It just concatenates these strings and inserts spaces in between, but it is probably more convenient than a simple concatenation because it handles properly the undefined strings. If all strings are undefined, the result is also an undefined string.

Example:

 # Shifts the mappings 10 frames forward
 rfs_transform ("[100 199]", "300", "[400 999]")
 # result: "[100 199] 300 [400 999]"
 


[edit] Adapting Existing Scripts

Using FreezeFrame Using RemapFrames
BlankClip(length=100).ShowFrameNumber()
FreezeFrame(10, 11, 10)
FreezeFrame(15, 16, 16)
FreezeFrame(20, 24, 21)
FreezeFrame(30, 32, 31)
FreezeFrame(35, 36, 36)
BlankClip(length=100).ShowFrameNumber()
RemapFrames(mappings="[10 11] 10
                      [15 16] 16
                      [20 24] 21
                      [30 32] 31
                      [35 36] 36")
Using ApplyRange Using ReplaceFramesSimple
BlankClip(length=100).ShowFrameNumber()
ApplyRange(10, 11, "SomeFilter")
ApplyRange(15, 16, "SomeFilter")
ApplyRange(20, 24, "SomeFilter")
ApplyRange(30, 32, "SomeFilter")
ApplyRange(35, 36, "SomeFilter")
src = BlankClip(length=100).ShowFrameNumber()
filtered = src.SomeFilter()
ReplaceFramesSimple(src, filtered,
\                   mappings="[10 11]
                              [15 16]
                              [20 24]
                              [30 32]
                              [35 36]")

[edit] Revision History

  • 0.4.1
    • It is now allowed for a downstream filter to request a frame out of range.
    • rfs_transform now accepts an undefined mapping string as input.
  • 0.4.0
    • Added remf, remfs, rfs, rfs_merge and rfs_transform.
  • 0.3.1
    • Fixed RemapFrames which was seriously broken because I forgot that initial clip parameters can't be optional. As a consequence, I had to rearrange RemapFrames's parameter order.
  • 0.3.0
    • Added ReplaceFramesSimple.
  • 0.2.0
    • Added RemapFramesSimple.
  • 0.1.1
    • Now retains field parity information of the remapped frames.
  • 0.1.0
    • Initial release.


[edit] Archived Downloads

Version Download Mirror
v0.4.1-avs26 RemapFrames-0.4.1-avs26.zip RemapFrames-0.4.1-avs26.zip
v0.4.1 RemapFrames-0.4.1.zip RemapFrames-0.4.1.zip


[edit] External Links

  • GitHub - RemapFrames_audiomod; this is a modification that also remaps audio. Only works with the "simple" filter.






Back to External Filters


Personal tools