my attempt at a subtitle utility after all the existing ones I tried failed me
Ondřej Hruška e5ee4fc6dc
cleaned up dependencies
1 year ago
src cleaned up dependencies 1 year ago
test add a readme 1 year ago
.gitignore add a readme 1 year ago
Cargo.lock cleaned up dependencies 1 year ago
Cargo.toml cleaned up dependencies 1 year ago
LICENSE add mit license 1 year ago cleaned up dependencies 1 year ago

srtune 0.3.0

'srtune' helps you edit a .srt file to match a video. Input and output can be either a file, or a stream, so you can pipe multiple invocations to create more complex operations. However, a single invocation should suffice in most cases.

An example invocation, used to adapt a full-length subtitle track to a shorter version of "Whisper of the Heart", looks like this:

srtune -o -M235=15:06.7 -M309=24:15 -M412=32:12 \
  -M411=32:01 -M762=58:51 -M895=1:08:33 -M1125=1:26:28 -M01:44:22=01:41:37.3

Times are specified with colons (required) and always include seconds (HH:MM:SS, MM:SS, 0:SS, :SS). Decimal point in the seconds part, if needed, can be either a period or a comma; times can be copied from the .srt file. Numbers without colons are assumed to be subtitle indices.

The tool can be used iteratively, adjusting the invocation until the generated subtitle file matches the audio track. You can reload the file in VLC by dragging it onto the player window. To make this work, subtitle times specified in arguments are the ones seen in the output file (after shifts and moving), while entry indices are those from the input file.

Using indices makes it easier to specify a subtitle to alter, but it is tied to the one .srt file. Times are harder to write, but the one configuration will work for any locatization or variant of the file,so long as it is intended for the same version of the movie. Enable debug logging with '-v' to see times you can use in place of indices.

Indices are normally not renumbered, so the output file can be used as a reference for both times and indices when you work out the right set of arguments. The flag '--renumber' will give each output entry a new sequential number. Please note that, once renumbered, the indices in the output file should no longer be used in the command invocation, as there can be (and often will be) differences from the original file.

    srtune [FLAGS] [OPTIONS] [--] [INFILE]

    -h, --help        Prints help information
    -r, --renumber    Renumber all emitted entries with sequential 1-based numbers.
    -v                Increase the logging verbosity; can be used multiple times
    -V, --version     Prints version information

    -M, --automove <ENTRY=VIDEOTIME>...    Move subtitles starting at a given time or index to align with a matching
                                           audio track time. This argument can be given multiple times. Some subtitles
                                           may be dropped if they fall outside the timeline after the move.
    -S, --autoscale <SUBTIME=VIDEOTIME>    Calculate scaling based on a perceived difference. The scaling is related to
                                           the first emitted subtitle; align it with '--move'. This overrides '--scale'.
    -d, --durscale <RATIO>                 Scale durations, can be combined with '--scale' or '--autoscale'. The given
                                           value will always be multiplied by the absolute time scale. 1 means identity,
                                           1.1 makes all times 10% longer.
    -m, --move <OFFSET>                    Move all subtitles in time (e.g 12:00.15 or -0:44)
    -o, --output <OUTFILE>                 Output file, defaults to stdout
    -s, --scale <RATIO>                    Scale all subtitle times and durations to compensate for bitrate differences.
                                           1 means identity, 1.1 makes all times 10% longer. Scaling is relative to the
                                           first emitted subtitle; align it with '--move'. This option has no effect if
                                           '--autoscale' is used.

    <INFILE>    Input file, leave out for stdin