Skip to content
torque edited this page Sep 10, 2012 · 6 revisions

Table of Contents

  1. Introduction
  2. How It Works
  3. Table o' Knowledge
  4. Using Mocha

Introduction

In order to facilitate the tracking process, Aegisub-Motion can trim and encode the section of video corresponding to the currently selected lineset. This allows for motion segments to be quickly and easily loaded into Mocha (or other motion tracking software) for processing.

Read All About It

There are a few settings that are used by the trim function. A full list is provided in the table below. This section will cover how they are used, and how the trim function in general works.

The way the encoding function works is that it writes a formatted batch file/shell script to the disk and then executes said script. The script is run and deletes itself, generating the trimmed video.

This is all done via the encoding command, which is a config setting. The default uses x264 and looks like this (albeit without the linebreak, which is there for formatting purposes):

"#{encbin}" --crf 16 --tune fastdecode -i 250 --fps 23.976 --sar 1:1 --index "#{prefix}#{index}.index"
--seek #{startf} --frames #{lenf} -o "#{prefix}#{output}[#{startf}-#{endf}].mp4" "#{inpath}#{input}"

As you can see above, the encoding command can use a set of predefined tokens, which hopefully allow it to be very flexible with different encoders.

Encoding Command Tokens

Token Name Description Source
encbin The full path to the encoder binary, as set in the config global.encbin
input The filename of the video currently open in Aegisub. script header
inpath The full path to the directory containing the currently open video file. aegisub.decode_path
prefix The path defined as your prefix in the config. global.prefix
index The filename of the video currently open in Aegisub, but with the extension stripped (intended to be used for FFMS2's index file). input
output A convenient alias of index (intended to be used for the output filename). index
startf The start frame of the selected video segment. line times
endf The end frame of the selected video segment. line times
lenf The length of the selected video segement, in frames. endf-startf
startt The start time of the selected video segment, in seconds. startf
endt The end time of the selected video segment, in seconds. endf
lent The length of the selected video segment, in seconds. endt-startt
nl An alias for \n, a linebreak, necessary for compatibility with the simplistic config format. \n

An example of a more complex command (to give you an idea what is possible) is the default avs2yuv command, which uses avisynth to generate an image sequence to load into Mocha (if, for example, you don't want to install quicktime):

echo FFVideoSource("#{inpath}#{input}",cachefile="#{prefix}#{index}.index").trim(#{startf},#{endf}).ConvertToRGB.ImageWriter("#{prefix}#{output}-[#{startf}-#{endf}]\\",type="png").ConvertToYV12 > "#{prefix}encode.avs"#{nl}
mkdir "#{prefix}#{output}-[#{startf}-#{endf}]"#{nl}
"#{encbin}" -o NUL "#{prefix}encode.avs"
#{nl}del "#{prefix}encode.avs"

This command writes a 1-line avisynth script to a file, makes the directory for the image sequence to go in, generates the image sequence by running the avisynth script on the command line via avs2yuv, and then deletes the avisynth script it created.

Yet Another Dense Cluster of Information

Title Description Default
Encoder Binary The full path to whatever encoder binary you want the trimmed video to be encoded with.
Encoder The name of the encoder preset to use. Should be set to Custom with the Config macro if you change it away from one of the actual presets. x264
Prefix This is the text box that the data is put in. It will accept either the path to a file or the raw data itself. By default, if the text on the clipboard contains the expected header, it will be copied in automatically when the interface runs. This feature can be disabled. ?video
Trim GUI This sets whether or not to show a simple dialogue before running the encoding command for the [Trim][trim] macro. Generally, this can be safely disabled to save some time when trimming scenes. On
Clone this wiki locally