How it works



Avisynth, the open source video and audio frame-server, has the ability to measure the differences between adjacent frames in a video file.  If the difference in brightness, color, movement, etc. is great, a large metric number is generated for that frame.  If the difference is slight, the metric number generated is small.  Keeping track of these metric numbers for   each frame   is   the   key.     As   the   video   file   is   sent   through   Avisynth,   these   metric numbers,   paired   with   the corresponding frame numbers, can be written to a text file that can be later analyzed.

So, how does this help us in our quest for true progressive, flicker free captures of our 8mm, Super8, and 16mm films? First, you need a working projector that can play your films at a slow speed.  If you don't currently have a projector, garage sales, flea markets or charity stores are a good source.  Once you have one that can play the films at a slower than normal speed, you'll need to open it up and remove or disable the shutter*.  This is crucial because we want the camera to capture the frames as they're being pulled down in the projector gate without the interference of the shutter. This way your video camera will capture multiple, flicker free frames while the film is at rest in the projector gate, and a few blurry, moving frames while it is being pulled down to the next frame.  Those frames that are at rest will generate low metric numbers by Avisynth.  The blurry, moving frames will have high metric numbers because each frame will be quite different from the adjacent frames. By analyzing the metrics text file generated by Avisynth, Cine X-TractorCL is able to choose the best frame from the group of frames that have low metric numbers, and send them, one by one, to any video encoder that accepts Avisynth scripts.  The result... clean, progressive video captures of your movies!

*Warning: do not disable the film pulldown mechanism

For the best results it is recommended to use a matte white poster board on which to project your movies, with the video camera as close to the projector as possible to minimize perspective distortion of the captured image (there are Avisynth plugins that can correct perspective distortion).  A good location is directly under the projector lens.  Locate the poster board so the projected image is sharp and moderately bright.  Too close and the image will be overly bright with a hot spot, and result in a highly contrasted image with the video camera unable to capture the darker portions.  Too far and the image will not have enough contrast.  Experiment before you begin your main capture session.  You can use one of those rear projection contraptions sold as a DIY film to video conversion tool, but these tend to have grainy screens with a hot spot in the center.  The poster board in a completely dark room will give you an excellent image.  Also, use as many manual controls on your video camera as it allows, especially focus and turning off auto-exposure.

Below is the command line help output of Cine X-TractorCL:


Cine X-Tractor (Command Line) 1.0.0 by khaver (c)2014

AviSynth+ 0.1 (r1576, x86)

Usage: XTractorCL (videofile|@filelist) [switches]
       videofile = path to single video file
       @filelist = path to text file containing list of video files
Switches:
-h [0|1]      -h or -h 0, display short help.  -h 1, display full help
-f float      Output fps (18)
-r start,end  Subframe range (avisynth trim sytax) (all frames)
-c float      Cadence (-1 = calculate) (calculate)
-n int        Stats interval (0 = calculate) (10)
-s 0|1        Avisynth source filter=Directshow|template source (0)
-t file.avt   Template file
-p  0|1|2|3   Processing=none|pre|post|pre&post (0)
-e -1|0|1|2   Exposure=under|normal|over|auto (0)
-d            Delete temporary files
-l            Create log (CXT-date_time.log)
-x textfile   A text file containing a single command line that
              will be run for each generated output .avs file.
                Use < as the placeholder for the generated .avs file.
                Use > as the placeholder for the output file.
              Output file will be the name of the video file without
              the extension. Use quotes where appropriate.
              Example: "C:\Apps\x264.exe" --crf 24 -o "D:\encodes\>.mp4" "<"

Cine X-Tractor needs  one or  more video files  to process.  For a single file,

type the full path to the video file, using quotes if the path contains spaces.
If you want to  batch process  several video  files at  once, use @ immediately
followed by the  path to a text  file that contains the path to each video file
on separate  lines.  If the  path  to the  text file  has spaces, enclose it in
quotes.  The paths  of the  video  files  listed  in the text  file do not need
quotes.  The various  switches and parameters  available  to single  video clip
processing are also available, on a per clip basis in the batch list, by adding
additional values  after the  path to the  video  file  separated  by "|".  Any
parameters not included  will use the values  added to the  command line or the
default values.  These values must be added in the following order:

videofile|fps|start|end|exposure|source|cadence|processing|templatefile


See the command line switch definitions below for possible values.


-f    (fps) A floating point number  representing the actual  frame rate of the

      film.  This is usually 16 for 8mm films, 18 for Super 8, and 24 for 16mm.
      This will be the frame rate of your final  encoded video.  The default is
      18.

-r    (start,end) Integers that indicate to process  beginning at frame "start"

      and end at frame "end".  Entering 0 (zero) for the  end frame  means  "to
      the end of the clip".  The default is all frames.

-c    (cadence) A floating  point number  representing  the ratio  of the frame

      rate  of your  capture  device (camcorder), to  the  frame  rate  of your
      projector.  If your camcorder  captures  at  29.97fps and your  projector
      projects at 6fps, the cadence  value would  be 4.995.  This value is used
      to select the correct number of frames during sections of complete  black
      or other  solid  colors  in your film.  It's  also  used  to  verify  the
      accuracy of the  analysis  of the metric  file.  If  the total  number of
      frames of the output  file is not close  to the total number of frames of
      the source  clip  divided  by  the  cadence  number  than  Cine X-Tractor
      couldn't process the video accurately  enough and no  final output script
      will be  written.  This  usually  happens  with  underexposed  or  highly
      overexposed  films.  See the  exposure  switch  below.  The default is to
      have Cine X-Tractor  calculate the cadence  from the  metric file itself.
      This is done  in a  matter  of seconds  so it's usually  best to  use the
      default.  A value of -1 will  also  tell  Cine X-Tractor to calculate the
      cadence.

-n    (interval) An integer that changes the stats update interval.  Leave this

      at the default, which is 10, unless you use heavy pre-processing Avisynth
      functions that slow down  processing speed.  Then use a value of 0 (zero)
      to have Cine X-Tractor calculate the interval.  This takes a few seconds,
      but will provide more accurate real-time stats updating.

-s    (source) Either 0 (zero) or 1 (one).  The default,  0, tells  Avisynth to

      use your installed DirectShow  video decoders to decode your video clips.
      A value of 1 tells  Cine X-Tractor  to use  the Avisynth  source function
      found in the provided template file (see -t below).

-t    (templatefile) A path to a  template  file.  The template  file is a text

      file containing additional  Avisynth functions  that can be  added to the
      Avisynth analysis script and the final output Avisynth script.  If the -s
      switch  or the (source)  value in the  batch list is 1 (one), instead  of
      using a DirectShow decoder, Cine X-Tractor will  search the template file
      and look for a line containing "#__source__#".  If it finds one,  it will
      replace the default  DirectShow source  function in the  analysis  script
      with everything on the line after #__source__#.  This must be an Avisynth
      video source function, either an internal one, such as "AviSource" or one
      used by an installed Avisynth  input source  plugin.  If #__source__#  is
      not found, Cine X-Tractor will exit with an error or continue to the next
      file in a batch list.  If there are  more than one lines  pre-pended with
      #__source__#, the last one will be used.

      If the -p switch or  (processing) value is 1  (pre-processing)  or 3 (pre

      and  post  processing), Cine X-Tractor  will  search  the  template  file
      looking for lines pre-pended  with #__pre__#.  All lines  pre-pended with
      this will be added to the end of the analysis script.  This allows you to
      add functions that  may help in a more  accurate  analysis  of the video,
      such as cropping away parts of the captured frame irrelevant to analyzing
      the  film, like  the  film gate.  Another  possibility  would be  if your
      projector/camera setup allows you to capture the sprocket hole along with
      the image.  You could crop away the image leaving just the sprocket hole,
      and the adjacent frame comparison would clearly differentiate between the
      sprocket hole at  rest and  while the  film is  being pulled  down in the
      gate.  This would allow accurate  progressive frame  extraction no matter
      what the exposure of the film.

      If the -p switch or (processing) value is 2 (post processing) or 3,  Cine

      X-Tractor will search the template file looking for lines pre-pended with
      #__post__#.  All lines  pre-pended with this will be  added to the end of
      the final output Avisynth script.  Use these to enhance the output script
      with functions to crop,  resize, flip, de-noise, etc.,  your final video.

      There are many  Avisynth functions,  both internal and plugins,  that you

      can use to improve  the appearance of your films.  Take the time to learn
      the Avisynth scripting language.

      If the template file indicated does not exist,  no pre or post processing

      functions will be added to the analysis or final output Avisynth scripts.

-p    (processing) An integer value of 0, 1, 2 or 3.  A value of 0 (zero),  the

      default, means  no pre or post processing.  A value of 1 (one) means only
      add the pre-processing  functions  in the template  file to the  analysis
      script.  A value of 2 means only add the post processing functions in the
      template file to the  final output  script.  A value of 3 means  use both
      the pre and post processing functions in the template file.  If you use a
      value of 1,  2 or 3, you must also include the -t or (templatefile) path.
      If you don't,  or the  template  file  does not  exist,  no  pre or  post
      processing  functions  will  be added  to the  analysis or  final  output
      Avisynth scripts.

-e    (exposure) An integer value  representing the exposure of your films.  If

      the entirety of  the captured  clip is  underexposed,  use a value of -1.
      What this will do is  brighten and add  more contrast  to the video clip.
      This will help in the analysis of the video.  For normally exposed  film,
      the default value of 0 (zero) should be used.  For overexposed film,  use
      a value of 1.  This  will invert the video (negate it) and then tweak the
      brightness and  contrast.  For  film  that  contains  scenes  of  various
      exposures, a value of 2 will tell Cine X-Tractor to add a function to the
      analysis script that  automatically adjusts  the brightness of each frame
      to a normal level.  This setting  works extremely  well with all types of
      footage, but it does slow down the processing rate nearly by half.

-d    Tells Cine X-Tractor  to delete all the temporary files after processing.


-l    Create a log file in the format CXT-date_time.log.


-x    (textfile) Path to a text file containing a single command line that will

      be run for each generated final Avisynth output script.
          Use < as a placeholder for the path to the Avisynth output script.
          Use > as a placeholder for the output file name.
      This output file name will be the name  of your source video file without
      the path or extension.  Use quotes where appropriate.
          Example: "C:\Apps\x264.exe" --crf 24 -o "D:\encodes\>.mp4" "<"
      In this example, if the source video file is "D:\captures\Super 8-01.mov",
      the command line will be expaned to:
      "C:\Apps\x264.exe" --crf 24 -o "D:\encodes\Super 8-01.mp4" "D:\captures\
      Super 8-01.avs"