TimecodeFPS

From Avisynth wiki
Jump to: navigation, search
Abstract
Author natt
Version 2012-04-16
Download timecodefps.zip
Category Frame Rate Converters
License Modified BSD license
Discussion TASVideos Forum

Contents

Description

TimecodeFPS converts a clip from VFR to CFR. Timing information from clip is discarded, and matroska v2 timecodes from the timecodes file are used instead. Conversion is to any desired exact CFR framerate, as specified by fpsnum/fpsden. With report=true, an alternate debug/analysis display and info is used. Strictness of the conversion is controlled by the parameters threshone and threshmore.

Note: TimecodeFPS is a C-Plugin.

Requirements


Syntax and Parameters

TimecodeFPS (clip, string "timecodes", int "fpsnum", int "fpsden", bool "report", float "threshone", float "threshmore")


clip   = last
Input clip. Can be any AviSynth supported colorspace. Must have exactly the same number of frames as lines in timecodes. Input FPS is discarded. Audio, if it exists, is passed through untouched.


string  timescodes = "timecodes.txt"
Path to a matroska v2 timecodes file. Only matroska v2 timecodes files are supported.
Exactly one timecode is expected per frame, and it gives the start point of the frame. (The end point of a frame is implicitly the same as the start point of the next frame, except for the last frame, where a guess is made.) The timecodes should be non-negative and non-decreasing. The first timecode need not be at time zero, but that will be used as the start point for the CFR stream, so a non-zero start time may cause the introduction of blank frame(s) before the first real frame.


int  fpsden = 25
int  fpsnum = 1
An exact CFR framerate to convert to. Any legal values are valid. Choosing the "right" framerate for a source should be done with report mode; there is no automatic detection.


bool  report = false
If false, TimecodeFPS simply does the conversion as expected. If true, an informative messagebox is shown on script load, and the returned frames are instead a timing track display.
The informative message box shows fpsnum, fpsden, number of dups of input frames, number of drops of input frames, average timing error in ms, and threshone and threshmore. Every drop is an input frame that is not sent to the output. Every dup is an input frame being displayed more than once to keep timing straight. The error value, in ms, is the average difference between original frame starts and the frame starts in the resulting stream. In some cases it can be used to detect jitter and drift, but don't bank too much on it.
The timing track display changes the video clip to 640x32 RGB32. Two rows of boxes are shown, which are visual representations of timing of this frame and nearby frames in the original VFR track and the resulting CFR track. The current frame in CFR is blue; the current frame in VFR is green.


float  threshone = 0.4
float  threshmore = 0.9
Controls the thresholds for the VFR->CFR algorithm. The algorithm is rather simple; it runs through the entire input track in sequence. For each input frame, it computes how much "space" there is for the frame: That is, the difference between the frame's VFR end time and the frame's CFR start time, the latter being determined by how many frames have been inserted into the output stream already.
This absolute time delta is converted to a unitless number relative to the CFR framerate, so that 1.0 = room for exactly one frame at the specified CFR rate. Then 0 or more copies of the input frame are inserted into the output track. The first copy is inserted if the available space is greater than threshone, and additional copies are inserted as long as the available space is greater than threshmore. (Available space decrements by 1.0 every time a frame is inserted).
With these parameters, the "strictness" of the conversion is defined. Threshone = threshmore = 0.5 will be the most accurate in preserving original timing. The default settings allow for "frame preserving" operation: A lower threshold for a first copy and a higher threshold for a second copy means timing can be sacrificed for the goal of getting each frame in the stream at least once. Experimentation with the report tool is advised.


Examples

Note: In order to get timing display along side output display, TimecodeFPS must be called twice with the same parameters, once with report on and once with report off. Here is an example:

clip1 = FFVideoSource ("foobar.mkv", timecodes="foobar.txt")

clipout = TimecodeFPS (clip1, "foobar.txt", 60000, 1001, false, 0.3, 0.9)
clippreview = TimecodeFPS (clip1, "foobar.txt", 60000, 1001, true, 0.3, 0.9)

#this requires reconciling colorspace and size differences first
StackVertical (clipout, clippreview)


Changelog

Version         Date            Changes
2012-04-16 2012-04-16 - Initial release


External Links




Back to External Filters

Personal tools