diff --git a/.gitignore b/.gitignore index 34fc68d..332008f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ /target **/*.rs.bk .idea/ -*.srt diff --git a/README.md b/README.md new file mode 100644 index 0000000..d8c63b2 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# srtune 0.2.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 source.srt -o whisper.srt -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. + +``` +USAGE: + srtune [FLAGS] [OPTIONS] [--] [INFILE] + +FLAGS: + -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 + +OPTIONS: + -M, --automove ... 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 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 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 Move all subtitles in time (e.g 12:00.15 or -0:44) + -o, --output Output file, defaults to stdout + -s, --scale 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. + +ARGS: + Input file, leave out for stdin +``` diff --git a/test/sample.srt b/test/sample.srt new file mode 100644 index 0000000..eb0c1bd --- /dev/null +++ b/test/sample.srt @@ -0,0 +1,27 @@ +20 +00:00:12,838 --> 00:00:20,762 +♪♪~ Country Roads take me home + +21 +00:00:20,762 --> 00:00:28,770 +♪♪~ To the place I belong + +22 +00:00:28,770 --> 00:00:32,758 +♪♪~ West Virginia + +23 +00:00:32,758 --> 00:00:36,812 +♪♪~ mountain momma + +24 +00:00:36,812 --> 00:00:40,766 +♪♪~ Take me home + +25 +00:00:40,766 --> 00:00:46,772 +♪♪~ Country Roads + +26 +00:00:46,772 --> 00:00:49,775 +♪♪~