docs: fix the README manually

This commit is contained in:
Emmanuel BENOîT 2025-04-11 12:26:51 +02:00
parent 6d1eb59d66
commit 17a8410e6c
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg

View file

@ -1,53 +1,76 @@
# SRTMerger
# SRT merger
## Overview
The `SRTMerger` script is designed to merge and manipulate subtitle files in the SRT format. It takes two SRT files and a set of commands to produce a merged output file. This tool can be particularly useful for re-aligning a translation for a slightly different edition of the same movie, where the new edition does not provide that translation. By using the commands, you can adjust the timing and mapping of subtitles to fit the new version.
The `srt_merge.py` script is designed to merge and manipulate subtitle files in
the SRT format. It takes two SRT files and a set of commands to produce a merged
output file.
This tool can be particularly useful for re-aligning a translation for a
slightly different edition of the same movie, where the new edition does not
provide that translation. By using the commands, you can adjust the timing and
mapping of subtitles to fit the new version.
(Also, this is an attempt to use AI to generate code. Could be better, could be
much worse.)
## Usage
The script is initialized with four parameters:
The script is given four parameters:
- `srt1_filename`: The filename of the first SRT file.
- `srt2_filename`: The filename of the second SRT file.
- `commands_filename`: The filename containing the commands to process.
- `output_filename`: The filename where the merged output will be saved.
The commands will be processed, generating merged subtitles which will be saved
as SRT to the specified `output_filename`.
## Supported Commands
The script supports the following commands:
### COPY
Copies subtitles from one file to the output, preserving their original timing.
**Syntax 1:**
**Syntax:**
```
COPY <source> <index_or_range>
```
- `<source>`: The source SRT file, specified as `1` or `2`.
- `<index_or_range>`: A single index or a range of indices (e.g., `5` or `5-10`).
- `<index_or_range>`: A single index or a range of indices (e.g., `5` or
`5-10`).
### MAP
Maps text from one file to another with a time offset. The command supports two different syntaxes.
Maps a sequence of subtitles from one stream to the other. The command supports
two different syntaxes.
**Syntax 1:**
```
MAP <text_source> <text_start> <time_start> <count>
```
- `<text_source>`: The source SRT file for text, specified as `1` or `2`.
- `<text_start>`: A range of indices in the text source (e.g., `5-10`).
- `<time_start>`: The starting index of the time to map.
- `<text_start>`: The starting index in the text source.
- `<time_start>`: The starting index in the time source.
- `<count>`: The number of subtitles to map.
**Syntax 2:**
```
MAP <text_source> <text_start> <time_start>
MAP <text_source> <text_range> <time_start>
```
- `<text_source>`: The source SRT file for text, specified as `1` or `2`.
- `<text_start>`: The starting index of the text to map.
- `<time_start>`: The starting index of the time to map.
- `<text_range>`: A range of indices in the text source (e.g., `5-10`).
- `<time_start>`: The starting index in the time source.
### SYNC
Aligns a subtitle text found only in one SRT file based on the time delta between that text and the previous entry. The entry used as the "time source" in the other stream must correspond to the previous entry in the text stream.
Aligns a subtitle text found only in one SRT file based on the time delta
between that text and the previous entry. The entry used as the "time source" in
the other stream must correspond to the previous entry in the text stream.
Typically it can be used to re-align subtitles for episode names, which are not
present in the original language's subtitles.
**Syntax:**
```
@ -55,19 +78,17 @@ SYNC <text_source> <text_index> <time_index>
```
- `<text_source>`: The source SRT file for text, specified as `1` or `2`.
- `<text_index>`: The index of the text to align.
- `<time_index>`: The index of the time entry in the other SRT file that corresponds to the previous entry in the text stream.
- `<time_index>`: The index of the time entry in the other SRT file that
corresponds to the previous entry in the text stream.
### PUT
Puts a specific text at a given index.
Outputs text at an existing entry's timestamp.
**Syntax:**
```
PUT <source> <index> <text>
```
- `<source>`: The source SRT file, specified as `1` or `2`.
- `<index>`: The index where the text should be placed.
- `<source>`: The SRT file used as the time source, specified as `1` or `2`.
- `<index>`: The index of the entry whose text is being provided.
- `<text>`: The text to insert.
## Output
The processed commands will generate a merged SRT file saved to the specified `output_filename`.