
TrimSubs - Cut and resync text subtitle files according to Trims in an 
existing Avisynth script


DESCRIPTION

This CLI utility parses a specified Avisynth script for a line with 
uncommented Trims, and cuts an input text subtitle file accordingly 
so the subtitles match the trimmed video.

There are three ways of specifying the line of the avs used:
· Parse the avs from top to bottom (default) or vice versa, and use the 
  first line with Trims found.
· Use a line with a specific comment at the end, e.g:
  Trim(0,99)++Trim(200,499)  # cuts
  It can be combined with a parsing order.
· Directly specifying the Trims line number, starting with 1.

A frame rate or timecode file (v1 or v2) is required, except for MicroDVD
subtitles.  The FPS can be either a float value or a fraction.  If the
timebase is not specified, the avs directory is searched for a timecode
file.  If a timecode can't be found then a default FPS value is used
instead.

If the path of the input subtitle file is not supplied in the input
parameter, the avs directory is searched for a subtitle file with the
same name as the Avisynth script.  If not given, the path of the output
subtitle is derived from the input file.

An encoding for the input file can be specified.  It should only be
necesary if it's neither a Unicode encoding nor the system's locale
encoding.  List of available encodings:
http://docs.python.org/py3k/library/codecs.html#standard-encodings

A new trimmed timecode v2 file can be generated optionally.  If a path
is not given, then is derived from the input timecode or the avs script.

Supported subtitle formats: ASS, SSA, SRT, SUB (MicroDVD).


COMMAND LINE OPTIONS

usage: TrimSubs.py script.avs                                                            
                   [-h [{doc}]] [-V] [-v] [-r] [-l LABEL] [-g LINE] [-f FPS]             
                   [-t [OTC]] [-i [INPUT]] [-c ENCODING] [-o OUTPUT]  

Info arguments:
  -h [{doc}], --help [{doc}]
                        Show a help message and exit. Add 'doc' to 
                        include also the documentation
  -V, --version         Show program's version number and exit

Required arguments:
  script.avs            Avisynth script containing Trims

Optional arguments:
  (--input or --otc parameter is required)

  -v, --verbose         Show detailed info
  -r, --reversed        Parse the avs from bottom to top
  -l LABEL, --label LABEL
                        Use the Trims from the line in the avs that ends in 
                        a commentary with LABEL
  -g LINE, --line LINE  Use the Trims from the line nº LINE
  -f FPS, --fps FPS     Frame rate or timecode file (v1 or v2). If omitted,
                        search for a timecode file or default to 24000/1001
  -t [OTC], --otc [OTC]
                        Output a new timecode file. Path optional
  -i [INPUT], --input [INPUT]
                        Input subtitle file. If INPUT is not specified, 
                        search for a valid input file
  -c ENCODING, --encoding ENCODING
                        Input subtitle file encoding
  -o OUTPUT, --output OUTPUT
                        Custom path for the output subtitle file


CHANGELOG

  0.1 [2011-12-30]: initial release
  0.2 [2012-01-29]: added --line parameter 
                    support for negative second member of the Trim pair


LICENSES

This program is a compiled Python script. It uses PySubs as subtitle 
framework. Source code is provided in the 'src' directory. 

TrimSubs Doom9 Forum thread: http://forum.doom9.org/showthread.php?t=163653
PySubs homepage: https://github.com/tigr42/pysubs
Python homepage: http://www.python.org/


LICENSE - TRIMSUBS

Copyright (C) 2011, 2012  vdcrim (http://forum.doom9.org/member.php?u=203325)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.html.


LICENSE - PYSUBS

Copyright (c) 2011 Tigr <tigr42@centrum.cz>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
