Improve the README with details about the processing workflow of the script.

This commit is contained in:
Frédéric Tronel
2025-09-19 16:32:11 +02:00
parent 7e5a500279
commit 10234d67da

View File

@@ -15,12 +15,37 @@ to a reference frame (so called I-frames). These frames are only present roughly
which corresponds to quite long duration (in the order of a second). which corresponds to quite long duration (in the order of a second).
I really want to cut the movie with a better precision. So I have written a Python script I really want to cut the movie with a better precision. So I have written a Python script
that leverages _ffmpeg_, _ffprobe_ and _mkvmerge_ to do the job with the required precision. that leverages _ffmpeg_, _ffprobe_ and _mkvmerge_, _subvodocr_ to do the job with the required precision.
# Parameters # Parameters
# How does it work ? # How does it work ?
The processing follows a quite long pipeline:
1. The original .ts file is first transformed into an .mp4 file using _ffmpeg_ to correct timestamps:
2. The .mp4 is then transformed into a Matroska container (which is the default container) still using _ffmpeg_:
3. Then the movie is then cut using the indications passed as parameters. It is possible to give as many parts as needed.
Each part is treated with the same algorithm.
Trouver l'estampille de la trame 'I' la plus proche (mais postérieure) au début de la portion.
Trouver l'estampille de la trame 'I' la plus proche (mais antérieure) à la fin de la portion.
On a alors
debut ----- trame --------- trame --------- fin.
'B/P' 'B/P'* 'I' 'I' 'B/P'* 'B/P'
Si la trame de début est déjà 'I', il n'y a rien à faire (idem pour la fin).
Sinon on extrait les trames 'B' ou 'P' depuis le début jusqu'à la trame 'I' non incluse
4. Then each part that have been previously obtained are merged using _mkvmerge_:
5. The subtitles (image based) are then extracted using _mkvextract_:
6. These images are then processed using _vobsubocr_ to create SRT files:
7. The SRT files are then remuxed inside the Matroska container using _mkvmerge_:
# How to determine where to cuts # How to determine where to cuts
Use `mpv --osd-fractions --osd-level=3 ./movie.ts` Use `mpv --osd-fractions --osd-level=3 ./movie.ts`