Switch to audio fingerprinting based syncing (#393)

* rename merge-auto-tolerance -> merge-time-tolerance

* move format_time_delta to own file

* switch to audio fingerprinting based syncing

* move format_time_delta to own file

* simpler approach to determine negative time deltas

* add missing readme part for --sync-precision

* fix all clippy "errors"

* Use rust-native chromaprint port instead of ffmpeg

* buffer with 128kb instead of 32kb

* improve helps

* improve help

---------

Co-authored-by: bytedream <bytedream@protonmail.com>
This commit is contained in:
Simon 2024-05-02 00:35:13 +02:00 committed by GitHub
parent f237033aff
commit 72c574c883
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 555 additions and 325 deletions

View file

@ -462,7 +462,7 @@ The `archive` command lets you download episodes with multiple audios and subtit
In the best case, when multiple audio & subtitle tracks are used, there is only one *video* track and all other languages can be stored as audio-only.
But, as said, this is not always the case.
With the `-m` / `--merge` flag you can define the behaviour when an episodes' video tracks differ in length.
Valid options are `audio` - store one video and all other languages as audio only; `video` - store the video + audio for every language; `auto` - detect if videos differ in length: if so, behave like `video` - otherwise like `audio`.
Valid options are `audio` - store one video and all other languages as audio only; `video` - store the video + audio for every language; `auto` - detect if videos differ in length: if so, behave like `video` - otherwise like `audio`; `sync` - detect if videos differ in length: if so, it tries to find the offset of matching audio parts and removes the offset from the beginning, otherwise it behaves like `audio`.
Subtitles will always match the primary audio and video.
```shell
@ -482,15 +482,18 @@ The `archive` command lets you download episodes with multiple audios and subtit
Default are `200` milliseconds.
- <span id="archive-sync-start">Sync start</span>
- <span id="archive-sync-tolerance">Sync tolerance</span>
If you want that all videos of the same episode should start at the same time and `--merge` doesn't fit your needs (e.g. one video has an intro, all other doesn't), you might consider using the `--sync-start`.
It tries to sync the timing of all downloaded audios to match one video.
This is done by downloading the first few segments/frames of all video tracks that differ in length and comparing them frame by frame.
The flag takes an optional value determines how accurate the syncing is, generally speaking everything over 15 begins to be more inaccurate and everything below 6 is too accurate (and won't succeed).
When the syncing fails, the command is continued as if `--sync-start` wasn't provided for this episode.
Sometimes two video tracks are downloaded with `--merge` set to `sync` because the audio fingerprinting fails to identify matching audio parts (e.g. opening).
To prevent this, you can use the `--sync-tolerance` flag to specify the difference by which two fingerprints are considered equal.
Default is `7.5`.
Default is `6`.
- <span id="archive-sync-precision">Sync precision</span>
If you use `--merge` set to `sync` and the syncing seems to be not accurate enough or takes to long, you can use the `--sync-precision` flag to specify the amount of offset determination runs from which the final offset is calculated.
Default is `4`.
- <span id="archive-language-tagging">Language tagging</span>