dubweld 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dubweld-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Filip Klopec
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
dubweld-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: dubweld
3
+ Version: 0.1.0
4
+ Summary: Lay a dubbed audio track from one release of a video onto another release, lip-synced
5
+ Keywords: dub,dubbing,audio,sync,alignment,ffmpeg,mkv,pal-speedup
6
+ Author: theobaldik
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: End Users/Desktop
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
18
+ Classifier: Topic :: Multimedia :: Video :: Conversion
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: numpy>=1.26
22
+ Maintainer: theobaldik
23
+ Requires-Python: >=3.11, <3.15
24
+ Project-URL: Homepage, https://github.com/theobaldik/dubweld
25
+ Project-URL: Source, https://github.com/theobaldik/dubweld
26
+ Project-URL: Documentation, https://github.com/theobaldik/dubweld#readme
27
+ Project-URL: Changelog, https://github.com/theobaldik/dubweld/blob/master/CHANGELOG.md
28
+ Project-URL: Issues, https://github.com/theobaldik/dubweld/issues
29
+ Description-Content-Type: text/markdown
30
+
31
+ # dubweld
32
+
33
+ Lay a dubbed audio track from one release of a video onto a different release of the same video, lip-synced.
34
+
35
+ You have the release you want to keep (the **target**: better picture, original audio) and another release that
36
+ has the dub you want (the **donor**). The two rarely line up: the donor may be a PAL transfer running 4 % fast,
37
+ start at a different point, and be cut differently, with longer or shorter fades at act breaks, or scenes added
38
+ or missing. A single offset or a single stretch can't fix that. dubweld finds the speed ratio, every offset and
39
+ every cut automatically. It renders the dub onto the target's timeline, muxes it in as an extra track, and then
40
+ checks its own result.
41
+
42
+ ```console
43
+ $ dubweld run target.mkv donor.m4v -o synced.mkv --lang cze --name "Czech dub"
44
+ speed ratio 1.0427083333 (pal, snapped)
45
+
46
+ segments (target time):
47
+ 1 0:01.5 - 4:37.0 offset +1.5443 s (donor 0:00.0 - 4:24.1)
48
+ 2 4:39.4 - 11:37.9 offset +4.0070 s (donor 4:24.1 - 11:05.5)
49
+ 3 11:40.2 - 20:50.4 offset +6.2702 s (donor 11:05.5 - 19:53.1)
50
+ 4 20:52.7 - 21:36.9 offset +8.6356 s (donor 19:53.1 - 20:35.5)
51
+
52
+ cuts (listen around these):
53
+ 4:37.0 +1.544 -> +4.007 target has 2.46 s extra, filled [high; black: donor fades to black 0.54 s at 4:36.5]
54
+ 11:37.9 +4.007 -> +6.270 target has 2.26 s extra, filled [high; black: donor fades to black 0.75 s at 11:37.2]
55
+ 20:50.4 +6.270 -> +8.636 target has 2.37 s extra, filled [high; black: donor fades to black 0.67 s at 20:49.7]
56
+
57
+ verification: PASS
58
+ 39 of 316 audible windows match at offset 0 (±40 ms); 18 confident ones: median 0.9 ms, max 3.1 ms, bias +0.8 ms
59
+ ```
60
+
61
+ The output is a copy of the target with every track untouched (video is never re-encoded) plus the dub. It comes
62
+ with `synced.plan.json`, an editable plan, and `synced.html`, a report with the offset plot, the cuts and their
63
+ evidence, and the verification.
64
+
65
+ ## How it works
66
+
67
+ A dub keeps the original **music and effects** (M&E): only the dialogue is replaced. dubweld matches the two
68
+ releases on that shared M&E, using language-agnostic band-energy features that ignore loudness and EQ differences
69
+ between the mixes. The matches are accurate to about a millisecond.
70
+
71
+ 1. **Speed ratio.** dubweld tries the ratio implied by the frame rates first (25 vs 23.976 fps means a PAL speed-up),
72
+ then the other standard ratios. It picks the one under which confident matches stay flat and don't drift (PAL
73
+ and 25/24 differ by only 0.1%). It never settles for
74
+ a loose estimate: being 3×10⁻⁴ off drifts 0.3 s over an episode. A free-form estimate is used only when no
75
+ standard ratio fits, and dubweld warns loudly when that happens.
76
+ 2. **Offsets.** It slides 8 s windows of the donor over the whole target (normalized cross-correlation, coarse to
77
+ fine, sub-frame accurate), then looks for *levels*: tight clusters (±10 ms) of high-scoring windows. The dubbed
78
+ dialogue roughly lines up with the original dialogue and forms a second, looser cluster 0.2–0.3 s away, sometimes
79
+ with *more* windows than the true level. dubweld prefers crispness over window count; the video only breaks
80
+ ties between equally crisp levels. A donor edit of a single frame (a 40 ms step) shows up as two levels, and
81
+ neither makes the other look loose.
82
+ 3. **Segments and cuts.** A Viterbi pass assigns every window to a level. Offsets may jump up (the target has extra
83
+ material, left as a gap), jump down (the donor has extra material, which is dropped) or return to an earlier
84
+ level. There is no limit on jump size or segment length: the donor's unmatched start and end get a second look
85
+ with 4 s windows, which finds a closing jingle a few seconds long. A cut is first narrowed by an audio
86
+ changepoint, then pinned by the strongest clue in that range: a fade to black in the donor's video, a scene cut,
87
+ silence. Each cut records its evidence and confidence.
88
+ 4. **Render.** The donor is resampled (not time-stretched), which also undoes a PAL speed-up's pitch rise. Each
89
+ segment is placed at its offset with 30 ms crossfades, and the gaps are filled with silence or the target's own
90
+ audio. The donor is decoded in one sequential pass, never seeked, so placement is sample-accurate.
91
+ 5. **Verify.** The rendered track is re-matched against the target. dubweld reports the residual offsets, the stretches
92
+ it could not check, and any part where several windows agree on a non-zero offset. Such a part fails the
93
+ verification, unless it looks like the dialogue match in a segment that matches elsewhere: then it only warns.
94
+
95
+ ## Requirements
96
+
97
+ - Python 3.11+ and numpy
98
+ - `ffmpeg` and `ffprobe`
99
+ - `mkvmerge` (MKVToolNix), recommended; without it dubweld muxes with ffmpeg
100
+
101
+ ## Install
102
+
103
+ ```console
104
+ uv tool install dubweld
105
+ # or
106
+ pipx install dubweld
107
+ ```
108
+
109
+ For the latest development version, install from `git+https://github.com/theobaldik/dubweld` instead.
110
+
111
+ ## Usage
112
+
113
+ ```
114
+ dubweld run TARGET DONOR -o OUT.mkv [options] # analyze + render + verify
115
+ dubweld analyze TARGET DONOR [-o plan.json] [--report plan.html] [analysis options]
116
+ dubweld render TARGET DONOR plan.json -o OUT.mkv [render options]
117
+ dubweld verify TARGET OUT.mkv [--target-track N] [--dub-track N]
118
+ ```
119
+
120
+ Analysis options:
121
+
122
+ | Option | Meaning |
123
+ |---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
124
+ | `--target-track N`, `--donor-track N` | audio stream of the target / donor, counted among audio streams (default 0) |
125
+ | `--ratio R` | `auto` (default), `pal` (25/23.976), `pal24` (25/24), `ntsc` (24/23.976), `1`, any of them with `-inv`, a number, or a fraction like `25/23.976` |
126
+ | `--no-video` | don't use the videos to place cuts |
127
+ | `--max-offset S` | only search offsets within ±S seconds (faster on long files) |
128
+
129
+ Render options:
130
+
131
+ | Option | Meaning |
132
+ |----------------------------------------|---------------------------------------------------------------------------------------------------------------|
133
+ | `--lang` | language of the dub track (default `und`) |
134
+ | `--name` | track name (default `Dub`) |
135
+ | `--fill silence\|original` | what plays where the donor has nothing (default silence) |
136
+ | `--codec aac\|opus\|flac`, `--bitrate` | dub codec (default AAC 192k) |
137
+ | `--default original\|dub` | which audio track is flagged default (default original) |
138
+ | `--pitch shift\|keep` | `shift` resamples (right for PAL donors); `keep` time-stretches, for donors that were already pitch-corrected |
139
+ | `--crossfade S` | crossfade at joins (default 0.03 s) |
140
+ | `--force` | overwrite the output |
141
+
142
+ Global options: `-v` / `-vv` for more output, `-q` for less, `--no-cache` / `--cache-dir` for the feature cache (by
143
+ default `~/.cache/dubweld`, keyed by file size and modification time).
144
+
145
+ Exit codes: 0 ok, 1 error, 2 usage error, 3 verification failed, 130 interrupted.
146
+
147
+ ### The listen-and-fix loop
148
+
149
+ 1. Run `dubweld run`, or `dubweld analyze` followed by `dubweld render`.
150
+ 2. Listen around the cuts it prints, and in the stretches the verification lists as unchecked.
151
+ 3. If something is off, edit the plan. The segments' `target_start`, `target_end` and `offset` (seconds) are what
152
+ renders; everything else is informational. Then re-render with `dubweld render TARGET DONOR plan.json -o synced.mkv`.
153
+
154
+ ## Using as a library
155
+
156
+ The `dubweld` package holds the whole pipeline, without global state, configuration files or environment variables:
157
+
158
+ ```console
159
+ pip install dubweld # or `uv add dubweld`
160
+ ```
161
+
162
+ ```python
163
+ from pathlib import Path
164
+
165
+ from dubweld import DubweldError, RenderOptions, analyze, render, verify
166
+
167
+ target, donor = Path("target.mkv"), Path("donor.m4v")
168
+ try:
169
+ plan = analyze(target, donor)
170
+ plan.save(Path("synced.plan.json")) # editable; Plan.load() reads it back
171
+ output = render(plan, target, donor, Path("synced.mkv"), RenderOptions(language="cze", name="Czech dub"))
172
+ report = verify(target, output, pieces=[(s.target_start, s.target_end) for s in plan.segments])
173
+ print(report.verdict) # pass, warn or fail; report.describe() says why
174
+ except DubweldError as e:
175
+ ... # the inputs are untouched and no partial output is left behind
176
+ ```
177
+
178
+ - `analyze()` takes `AnalyzeOptions` (audio streams, a forced ratio, `use_video`, a feature `cache_dir`) and returns
179
+ a `Plan`: the speed ratio, the `segments` with their offsets, and the `cuts` with their evidence. Times are
180
+ seconds; target time = donor time × `plan.ratio` + the segment's offset.
181
+ - `plan.to_target(donor_time)` and `plan.to_donor(target_time)` map times between the releases, for example to
182
+ retime the donor's subtitles. They return `None` where material isn't played.
183
+ - `write_report(path, plan, report)` writes the HTML report.
184
+ - Errors are `ProbeError`, `ToolError`, `AnalysisError`, `PlanError` and `RenderError`, all subclasses of
185
+ `DubweldError`.
186
+ - `ffmpeg` and `ffprobe` must be on `PATH`, or pass `Tools(ffmpeg=..., ffprobe=..., mkvmerge=...)` to each call.
187
+ - Long steps take a `progress` callback. The library logs through `logging` under `dubweld.*` and configures no
188
+ handlers.
189
+
190
+ ## Limitations
191
+
192
+ - The releases must share the music and effects. A re-scored or remixed dub can't be matched.
193
+ - A segment shorter than about 10 s is hard to see with 8 s windows, except at the very start or end of the donor.
194
+ - Verification sees only the music and effects. In dialogue-heavy stretches it can't check anything, and it lists
195
+ them; listen there.
196
+ - At a downward jump (the donor has extra material), the target is assumed continuous across the cut.
197
+ - `--pitch keep` uses ffmpeg's `rubberband` (or `atempo`). Their latency is not compensated, so check the
198
+ verification.
199
+ - The output is always Matroska.
200
+
201
+ ## Credits
202
+
203
+ The approach builds on the experience of syncing a real dub with
204
+ [DubSync Studio](https://github.com/bleronmorina/dubsync) (ideas only; no code is used). Related tools:
205
+ [risenxxx/dubsync](https://github.com/risenxxx/dubsync), [DubaLign](https://github.com/Arata12/DubaLign),
206
+ [AudioAlign](https://github.com/protyposis/AudioAlign).
207
+
208
+ ## License
209
+
210
+ [MIT](https://github.com/theobaldik/dubweld/blob/master/LICENSE)
@@ -0,0 +1,180 @@
1
+ # dubweld
2
+
3
+ Lay a dubbed audio track from one release of a video onto a different release of the same video, lip-synced.
4
+
5
+ You have the release you want to keep (the **target**: better picture, original audio) and another release that
6
+ has the dub you want (the **donor**). The two rarely line up: the donor may be a PAL transfer running 4 % fast,
7
+ start at a different point, and be cut differently, with longer or shorter fades at act breaks, or scenes added
8
+ or missing. A single offset or a single stretch can't fix that. dubweld finds the speed ratio, every offset and
9
+ every cut automatically. It renders the dub onto the target's timeline, muxes it in as an extra track, and then
10
+ checks its own result.
11
+
12
+ ```console
13
+ $ dubweld run target.mkv donor.m4v -o synced.mkv --lang cze --name "Czech dub"
14
+ speed ratio 1.0427083333 (pal, snapped)
15
+
16
+ segments (target time):
17
+ 1 0:01.5 - 4:37.0 offset +1.5443 s (donor 0:00.0 - 4:24.1)
18
+ 2 4:39.4 - 11:37.9 offset +4.0070 s (donor 4:24.1 - 11:05.5)
19
+ 3 11:40.2 - 20:50.4 offset +6.2702 s (donor 11:05.5 - 19:53.1)
20
+ 4 20:52.7 - 21:36.9 offset +8.6356 s (donor 19:53.1 - 20:35.5)
21
+
22
+ cuts (listen around these):
23
+ 4:37.0 +1.544 -> +4.007 target has 2.46 s extra, filled [high; black: donor fades to black 0.54 s at 4:36.5]
24
+ 11:37.9 +4.007 -> +6.270 target has 2.26 s extra, filled [high; black: donor fades to black 0.75 s at 11:37.2]
25
+ 20:50.4 +6.270 -> +8.636 target has 2.37 s extra, filled [high; black: donor fades to black 0.67 s at 20:49.7]
26
+
27
+ verification: PASS
28
+ 39 of 316 audible windows match at offset 0 (±40 ms); 18 confident ones: median 0.9 ms, max 3.1 ms, bias +0.8 ms
29
+ ```
30
+
31
+ The output is a copy of the target with every track untouched (video is never re-encoded) plus the dub. It comes
32
+ with `synced.plan.json`, an editable plan, and `synced.html`, a report with the offset plot, the cuts and their
33
+ evidence, and the verification.
34
+
35
+ ## How it works
36
+
37
+ A dub keeps the original **music and effects** (M&E): only the dialogue is replaced. dubweld matches the two
38
+ releases on that shared M&E, using language-agnostic band-energy features that ignore loudness and EQ differences
39
+ between the mixes. The matches are accurate to about a millisecond.
40
+
41
+ 1. **Speed ratio.** dubweld tries the ratio implied by the frame rates first (25 vs 23.976 fps means a PAL speed-up),
42
+ then the other standard ratios. It picks the one under which confident matches stay flat and don't drift (PAL
43
+ and 25/24 differ by only 0.1%). It never settles for
44
+ a loose estimate: being 3×10⁻⁴ off drifts 0.3 s over an episode. A free-form estimate is used only when no
45
+ standard ratio fits, and dubweld warns loudly when that happens.
46
+ 2. **Offsets.** It slides 8 s windows of the donor over the whole target (normalized cross-correlation, coarse to
47
+ fine, sub-frame accurate), then looks for *levels*: tight clusters (±10 ms) of high-scoring windows. The dubbed
48
+ dialogue roughly lines up with the original dialogue and forms a second, looser cluster 0.2–0.3 s away, sometimes
49
+ with *more* windows than the true level. dubweld prefers crispness over window count; the video only breaks
50
+ ties between equally crisp levels. A donor edit of a single frame (a 40 ms step) shows up as two levels, and
51
+ neither makes the other look loose.
52
+ 3. **Segments and cuts.** A Viterbi pass assigns every window to a level. Offsets may jump up (the target has extra
53
+ material, left as a gap), jump down (the donor has extra material, which is dropped) or return to an earlier
54
+ level. There is no limit on jump size or segment length: the donor's unmatched start and end get a second look
55
+ with 4 s windows, which finds a closing jingle a few seconds long. A cut is first narrowed by an audio
56
+ changepoint, then pinned by the strongest clue in that range: a fade to black in the donor's video, a scene cut,
57
+ silence. Each cut records its evidence and confidence.
58
+ 4. **Render.** The donor is resampled (not time-stretched), which also undoes a PAL speed-up's pitch rise. Each
59
+ segment is placed at its offset with 30 ms crossfades, and the gaps are filled with silence or the target's own
60
+ audio. The donor is decoded in one sequential pass, never seeked, so placement is sample-accurate.
61
+ 5. **Verify.** The rendered track is re-matched against the target. dubweld reports the residual offsets, the stretches
62
+ it could not check, and any part where several windows agree on a non-zero offset. Such a part fails the
63
+ verification, unless it looks like the dialogue match in a segment that matches elsewhere: then it only warns.
64
+
65
+ ## Requirements
66
+
67
+ - Python 3.11+ and numpy
68
+ - `ffmpeg` and `ffprobe`
69
+ - `mkvmerge` (MKVToolNix), recommended; without it dubweld muxes with ffmpeg
70
+
71
+ ## Install
72
+
73
+ ```console
74
+ uv tool install dubweld
75
+ # or
76
+ pipx install dubweld
77
+ ```
78
+
79
+ For the latest development version, install from `git+https://github.com/theobaldik/dubweld` instead.
80
+
81
+ ## Usage
82
+
83
+ ```
84
+ dubweld run TARGET DONOR -o OUT.mkv [options] # analyze + render + verify
85
+ dubweld analyze TARGET DONOR [-o plan.json] [--report plan.html] [analysis options]
86
+ dubweld render TARGET DONOR plan.json -o OUT.mkv [render options]
87
+ dubweld verify TARGET OUT.mkv [--target-track N] [--dub-track N]
88
+ ```
89
+
90
+ Analysis options:
91
+
92
+ | Option | Meaning |
93
+ |---------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
94
+ | `--target-track N`, `--donor-track N` | audio stream of the target / donor, counted among audio streams (default 0) |
95
+ | `--ratio R` | `auto` (default), `pal` (25/23.976), `pal24` (25/24), `ntsc` (24/23.976), `1`, any of them with `-inv`, a number, or a fraction like `25/23.976` |
96
+ | `--no-video` | don't use the videos to place cuts |
97
+ | `--max-offset S` | only search offsets within ±S seconds (faster on long files) |
98
+
99
+ Render options:
100
+
101
+ | Option | Meaning |
102
+ |----------------------------------------|---------------------------------------------------------------------------------------------------------------|
103
+ | `--lang` | language of the dub track (default `und`) |
104
+ | `--name` | track name (default `Dub`) |
105
+ | `--fill silence\|original` | what plays where the donor has nothing (default silence) |
106
+ | `--codec aac\|opus\|flac`, `--bitrate` | dub codec (default AAC 192k) |
107
+ | `--default original\|dub` | which audio track is flagged default (default original) |
108
+ | `--pitch shift\|keep` | `shift` resamples (right for PAL donors); `keep` time-stretches, for donors that were already pitch-corrected |
109
+ | `--crossfade S` | crossfade at joins (default 0.03 s) |
110
+ | `--force` | overwrite the output |
111
+
112
+ Global options: `-v` / `-vv` for more output, `-q` for less, `--no-cache` / `--cache-dir` for the feature cache (by
113
+ default `~/.cache/dubweld`, keyed by file size and modification time).
114
+
115
+ Exit codes: 0 ok, 1 error, 2 usage error, 3 verification failed, 130 interrupted.
116
+
117
+ ### The listen-and-fix loop
118
+
119
+ 1. Run `dubweld run`, or `dubweld analyze` followed by `dubweld render`.
120
+ 2. Listen around the cuts it prints, and in the stretches the verification lists as unchecked.
121
+ 3. If something is off, edit the plan. The segments' `target_start`, `target_end` and `offset` (seconds) are what
122
+ renders; everything else is informational. Then re-render with `dubweld render TARGET DONOR plan.json -o synced.mkv`.
123
+
124
+ ## Using as a library
125
+
126
+ The `dubweld` package holds the whole pipeline, without global state, configuration files or environment variables:
127
+
128
+ ```console
129
+ pip install dubweld # or `uv add dubweld`
130
+ ```
131
+
132
+ ```python
133
+ from pathlib import Path
134
+
135
+ from dubweld import DubweldError, RenderOptions, analyze, render, verify
136
+
137
+ target, donor = Path("target.mkv"), Path("donor.m4v")
138
+ try:
139
+ plan = analyze(target, donor)
140
+ plan.save(Path("synced.plan.json")) # editable; Plan.load() reads it back
141
+ output = render(plan, target, donor, Path("synced.mkv"), RenderOptions(language="cze", name="Czech dub"))
142
+ report = verify(target, output, pieces=[(s.target_start, s.target_end) for s in plan.segments])
143
+ print(report.verdict) # pass, warn or fail; report.describe() says why
144
+ except DubweldError as e:
145
+ ... # the inputs are untouched and no partial output is left behind
146
+ ```
147
+
148
+ - `analyze()` takes `AnalyzeOptions` (audio streams, a forced ratio, `use_video`, a feature `cache_dir`) and returns
149
+ a `Plan`: the speed ratio, the `segments` with their offsets, and the `cuts` with their evidence. Times are
150
+ seconds; target time = donor time × `plan.ratio` + the segment's offset.
151
+ - `plan.to_target(donor_time)` and `plan.to_donor(target_time)` map times between the releases, for example to
152
+ retime the donor's subtitles. They return `None` where material isn't played.
153
+ - `write_report(path, plan, report)` writes the HTML report.
154
+ - Errors are `ProbeError`, `ToolError`, `AnalysisError`, `PlanError` and `RenderError`, all subclasses of
155
+ `DubweldError`.
156
+ - `ffmpeg` and `ffprobe` must be on `PATH`, or pass `Tools(ffmpeg=..., ffprobe=..., mkvmerge=...)` to each call.
157
+ - Long steps take a `progress` callback. The library logs through `logging` under `dubweld.*` and configures no
158
+ handlers.
159
+
160
+ ## Limitations
161
+
162
+ - The releases must share the music and effects. A re-scored or remixed dub can't be matched.
163
+ - A segment shorter than about 10 s is hard to see with 8 s windows, except at the very start or end of the donor.
164
+ - Verification sees only the music and effects. In dialogue-heavy stretches it can't check anything, and it lists
165
+ them; listen there.
166
+ - At a downward jump (the donor has extra material), the target is assumed continuous across the cut.
167
+ - `--pitch keep` uses ffmpeg's `rubberband` (or `atempo`). Their latency is not compensated, so check the
168
+ verification.
169
+ - The output is always Matroska.
170
+
171
+ ## Credits
172
+
173
+ The approach builds on the experience of syncing a real dub with
174
+ [DubSync Studio](https://github.com/bleronmorina/dubsync) (ideas only; no code is used). Related tools:
175
+ [risenxxx/dubsync](https://github.com/risenxxx/dubsync), [DubaLign](https://github.com/Arata12/DubaLign),
176
+ [AudioAlign](https://github.com/protyposis/AudioAlign).
177
+
178
+ ## License
179
+
180
+ [MIT](https://github.com/theobaldik/dubweld/blob/master/LICENSE)
@@ -0,0 +1,45 @@
1
+ """
2
+ Lay a dubbed audio track from one release of a video onto another release, lip-synced.
3
+
4
+ plan = analyze(target, donor); render(plan, target, donor, output); verify(target, output)
5
+ """
6
+
7
+ from importlib.metadata import PackageNotFoundError, version
8
+
9
+ try:
10
+ __version__ = version("dubweld")
11
+ except PackageNotFoundError: # running from a source tree that is not installed
12
+ __version__ = "0.0.0"
13
+
14
+ from dubweld.analyze import AnalyzeOptions, ProgressCallback, analyze
15
+ from dubweld.errors import AnalysisError, DubweldError, PlanError, ProbeError, RenderError, ToolError
16
+ from dubweld.ffmpeg import Tools
17
+ from dubweld.plan import Cut, Evidence, Gap, InputRef, Plan, Segment
18
+ from dubweld.render import RenderOptions, render
19
+ from dubweld.report import write_report
20
+ from dubweld.verify import VerifyReport, verify
21
+
22
+ __all__ = [
23
+ "AnalysisError",
24
+ "AnalyzeOptions",
25
+ "Cut",
26
+ "DubweldError",
27
+ "Evidence",
28
+ "Gap",
29
+ "InputRef",
30
+ "Plan",
31
+ "PlanError",
32
+ "ProbeError",
33
+ "ProgressCallback",
34
+ "RenderError",
35
+ "RenderOptions",
36
+ "Segment",
37
+ "ToolError",
38
+ "Tools",
39
+ "VerifyReport",
40
+ "__version__",
41
+ "analyze",
42
+ "render",
43
+ "verify",
44
+ "write_report",
45
+ ]
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from dubweld.cli import main
4
+
5
+ sys.exit(main())