cutcaption 0.1.0__py3-none-any.whl
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.
- cutcaption/__init__.py +5 -0
- cutcaption/__main__.py +6 -0
- cutcaption/_version.py +3 -0
- cutcaption/chunking.py +240 -0
- cutcaption/cli.py +347 -0
- cutcaption/config.py +258 -0
- cutcaption/doctor.py +143 -0
- cutcaption/exporters/__init__.py +1 -0
- cutcaption/exporters/ass.py +97 -0
- cutcaption/exporters/json.py +67 -0
- cutcaption/exporters/srt.py +61 -0
- cutcaption/media.py +23 -0
- cutcaption/models.py +93 -0
- cutcaption/pipeline.py +151 -0
- cutcaption/render.py +76 -0
- cutcaption/styles.py +149 -0
- cutcaption/transcribe.py +131 -0
- cutcaption/utils/__init__.py +1 -0
- cutcaption/utils/ffmpeg.py +143 -0
- cutcaption/utils/logging.py +7 -0
- cutcaption/utils/paths.py +82 -0
- cutcaption-0.1.0.dist-info/METADATA +390 -0
- cutcaption-0.1.0.dist-info/RECORD +27 -0
- cutcaption-0.1.0.dist-info/WHEEL +5 -0
- cutcaption-0.1.0.dist-info/entry_points.txt +2 -0
- cutcaption-0.1.0.dist-info/licenses/LICENSE +21 -0
- cutcaption-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""Subprocess helpers for ffmpeg and ffprobe."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class FfmpegError(RuntimeError):
|
|
14
|
+
"""Base error for ffmpeg integration failures."""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FfmpegNotFoundError(FfmpegError):
|
|
18
|
+
"""Raised when ffmpeg or ffprobe cannot be found."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class FfmpegCommandError(FfmpegError):
|
|
22
|
+
"""Raised when an ffmpeg command exits unsuccessfully."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class MediaProbeError(FfmpegError):
|
|
26
|
+
"""Raised when ffprobe output cannot be read."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True, slots=True)
|
|
30
|
+
class MediaInfo:
|
|
31
|
+
path: Path
|
|
32
|
+
duration: float | None
|
|
33
|
+
width: int | None
|
|
34
|
+
height: int | None
|
|
35
|
+
video_codec: str | None
|
|
36
|
+
audio_codec: str | None
|
|
37
|
+
has_audio: bool
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def executable_exists(name: str) -> bool:
|
|
41
|
+
return shutil.which(name) is not None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def check_ffmpeg() -> bool:
|
|
45
|
+
return executable_exists("ffmpeg")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def check_ffprobe() -> bool:
|
|
49
|
+
return executable_exists("ffprobe")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def run_command(command: list[str]) -> subprocess.CompletedProcess[str]:
|
|
53
|
+
try:
|
|
54
|
+
result = subprocess.run(command, check=False, capture_output=True, text=True)
|
|
55
|
+
except FileNotFoundError as exc:
|
|
56
|
+
raise FfmpegNotFoundError(f"Required executable not found: {command[0]}") from exc
|
|
57
|
+
|
|
58
|
+
if result.returncode != 0:
|
|
59
|
+
stderr = result.stderr.strip() or "No stderr output."
|
|
60
|
+
raise FfmpegCommandError(
|
|
61
|
+
f"{command[0]} failed with exit code {result.returncode}: {stderr}"
|
|
62
|
+
)
|
|
63
|
+
return result
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def probe_media(path: Path) -> MediaInfo:
|
|
67
|
+
if not check_ffprobe():
|
|
68
|
+
raise FfmpegNotFoundError("ffprobe not found. Install ffmpeg to inspect media files.")
|
|
69
|
+
|
|
70
|
+
result = run_command(
|
|
71
|
+
[
|
|
72
|
+
"ffprobe",
|
|
73
|
+
"-v",
|
|
74
|
+
"error",
|
|
75
|
+
"-print_format",
|
|
76
|
+
"json",
|
|
77
|
+
"-show_format",
|
|
78
|
+
"-show_streams",
|
|
79
|
+
str(path),
|
|
80
|
+
]
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
try:
|
|
84
|
+
payload = json.loads(result.stdout)
|
|
85
|
+
except json.JSONDecodeError as exc:
|
|
86
|
+
raise MediaProbeError(f"Could not parse ffprobe output for {path}.") from exc
|
|
87
|
+
|
|
88
|
+
streams = payload.get("streams", [])
|
|
89
|
+
if not isinstance(streams, list):
|
|
90
|
+
raise MediaProbeError(f"Unexpected ffprobe stream output for {path}.")
|
|
91
|
+
|
|
92
|
+
video_stream = _first_stream(streams, "video")
|
|
93
|
+
audio_stream = _first_stream(streams, "audio")
|
|
94
|
+
return MediaInfo(
|
|
95
|
+
path=path,
|
|
96
|
+
duration=_duration(payload, video_stream),
|
|
97
|
+
width=_int_value(video_stream, "width"),
|
|
98
|
+
height=_int_value(video_stream, "height"),
|
|
99
|
+
video_codec=_str_value(video_stream, "codec_name"),
|
|
100
|
+
audio_codec=_str_value(audio_stream, "codec_name"),
|
|
101
|
+
has_audio=audio_stream is not None,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _first_stream(streams: list[Any], codec_type: str) -> dict[str, Any] | None:
|
|
106
|
+
for stream in streams:
|
|
107
|
+
if isinstance(stream, dict) and stream.get("codec_type") == codec_type:
|
|
108
|
+
return stream
|
|
109
|
+
return None
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _duration(payload: dict[str, Any], video_stream: dict[str, Any] | None) -> float | None:
|
|
113
|
+
format_payload = payload.get("format", {})
|
|
114
|
+
if isinstance(format_payload, dict):
|
|
115
|
+
duration = _float_value(format_payload, "duration")
|
|
116
|
+
if duration is not None:
|
|
117
|
+
return duration
|
|
118
|
+
return _float_value(video_stream, "duration")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _int_value(payload: dict[str, Any] | None, key: str) -> int | None:
|
|
122
|
+
if payload is None or key not in payload:
|
|
123
|
+
return None
|
|
124
|
+
try:
|
|
125
|
+
return int(payload[key])
|
|
126
|
+
except (TypeError, ValueError):
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _float_value(payload: dict[str, Any] | None, key: str) -> float | None:
|
|
131
|
+
if payload is None or key not in payload:
|
|
132
|
+
return None
|
|
133
|
+
try:
|
|
134
|
+
return float(payload[key])
|
|
135
|
+
except (TypeError, ValueError):
|
|
136
|
+
return None
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _str_value(payload: dict[str, Any] | None, key: str) -> str | None:
|
|
140
|
+
if payload is None:
|
|
141
|
+
return None
|
|
142
|
+
value = payload.get(key)
|
|
143
|
+
return value if isinstance(value, str) else None
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Path discovery and output naming helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from cutcaption.models import VIDEO_EXTENSIONS, OutputPaths, VideoJob
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def is_video_file(path: Path) -> bool:
|
|
11
|
+
return path.is_file() and path.suffix.lower() in VIDEO_EXTENSIONS
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def discover_inputs(input_path: Path, recursive: bool = False) -> list[Path]:
|
|
15
|
+
path = input_path.expanduser()
|
|
16
|
+
if path.is_file():
|
|
17
|
+
if not is_video_file(path):
|
|
18
|
+
supported = ", ".join(sorted(VIDEO_EXTENSIONS))
|
|
19
|
+
raise ValueError(
|
|
20
|
+
f"Unsupported file type: {path.name}. "
|
|
21
|
+
f"Supported video extensions are: {supported}."
|
|
22
|
+
)
|
|
23
|
+
return [path]
|
|
24
|
+
|
|
25
|
+
if path.is_dir():
|
|
26
|
+
candidates = path.rglob("*") if recursive else path.iterdir()
|
|
27
|
+
videos = sorted(
|
|
28
|
+
item
|
|
29
|
+
for item in candidates
|
|
30
|
+
if item.is_file() and item.suffix.lower() in VIDEO_EXTENSIONS
|
|
31
|
+
)
|
|
32
|
+
if not videos:
|
|
33
|
+
supported = ", ".join(sorted(VIDEO_EXTENSIONS))
|
|
34
|
+
raise FileNotFoundError(
|
|
35
|
+
f"No supported video files found in {path}. "
|
|
36
|
+
f"Supported extensions are: {supported}."
|
|
37
|
+
)
|
|
38
|
+
return videos
|
|
39
|
+
|
|
40
|
+
raise FileNotFoundError(f"Input does not exist: {path}")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def build_output_paths(input_video: Path, output_dir: Path | None) -> OutputPaths:
|
|
44
|
+
destination = output_dir.expanduser() if output_dir is not None else input_video.parent
|
|
45
|
+
destination.mkdir(parents=True, exist_ok=True)
|
|
46
|
+
stem = input_video.stem
|
|
47
|
+
return OutputPaths(
|
|
48
|
+
srt_path=destination / f"{stem}.srt",
|
|
49
|
+
ass_path=destination / f"{stem}.ass",
|
|
50
|
+
json_path=destination / f"{stem}.json",
|
|
51
|
+
captioned_video_path=destination / f"{stem}_captioned.mp4",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def folder_output_dir(input_path: Path, output_dir: Path | None) -> Path | None:
|
|
56
|
+
if output_dir is not None:
|
|
57
|
+
return output_dir
|
|
58
|
+
path = input_path.expanduser()
|
|
59
|
+
if path.is_dir():
|
|
60
|
+
return path / "captioned"
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def discover_videos(input_path: Path) -> list[Path]:
|
|
65
|
+
return discover_inputs(input_path)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def default_output_dir(input_path: Path, videos: list[Path]) -> Path:
|
|
69
|
+
if input_path.expanduser().is_dir() or len(videos) > 1:
|
|
70
|
+
return input_path.expanduser() / "captioned"
|
|
71
|
+
return videos[0].parent
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def build_video_job(video_path: Path, output_dir: Path | None) -> VideoJob:
|
|
75
|
+
output_paths = build_output_paths(video_path, output_dir)
|
|
76
|
+
return VideoJob(
|
|
77
|
+
source=video_path,
|
|
78
|
+
srt_path=output_paths.srt_path,
|
|
79
|
+
ass_path=output_paths.ass_path,
|
|
80
|
+
json_path=output_paths.json_path,
|
|
81
|
+
rendered_path=output_paths.captioned_video_path,
|
|
82
|
+
)
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cutcaption
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Fast local CLI/TUI for generating styled burned-in captions for videos.
|
|
5
|
+
Author: cutcaption contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: captions,subtitles,whisper,video,cli
|
|
8
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Multimedia :: Video
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: faster-whisper<2,>=1.1
|
|
21
|
+
Requires-Dist: pysubs2<2,>=1.7
|
|
22
|
+
Requires-Dist: rich<15,>=13.9
|
|
23
|
+
Requires-Dist: tomli<3,>=2.0; python_version < "3.11"
|
|
24
|
+
Requires-Dist: typer<1,>=0.12
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest<9,>=8.0; extra == "dev"
|
|
27
|
+
Requires-Dist: ruff<1,>=0.8; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# cutcaption
|
|
31
|
+
|
|
32
|
+
**cutcaption — CapCut-like captions from your terminal**
|
|
33
|
+
|
|
34
|
+
Generate clean, styled, burned-in captions for one video or a folder of videos using faster-whisper.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pipx install cutcaption
|
|
38
|
+
cutcaption video.mp4
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
By default, cutcaption transcribes your video, builds short creator-friendly captions, writes subtitles, and burns styled captions into a new video.
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cutcaption video.mp4
|
|
47
|
+
cutcaption ./videos --preset shorts --style pop
|
|
48
|
+
cutcaption video.mp4 --srt --no-burn
|
|
49
|
+
cutcaption doctor
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Common outputs:
|
|
53
|
+
|
|
54
|
+
- `video.srt` for standard subtitles
|
|
55
|
+
- `video.ass` when styled captions are needed for burning
|
|
56
|
+
- `video.json` when JSON metadata is enabled
|
|
57
|
+
- `video_captioned.mp4` for the burned-in captioned video
|
|
58
|
+
|
|
59
|
+
For folders, cutcaption writes to a `captioned/` folder unless you pass `--output`.
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
If you already have `pipx`:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pipx install cutcaption
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If you do not have `pipx` yet, install it first.
|
|
70
|
+
|
|
71
|
+
macOS/Linux:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
python3 -m pip install --user pipx
|
|
75
|
+
python3 -m pipx ensurepath
|
|
76
|
+
pipx install cutcaption
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Windows:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
py -m pip install --user pipx
|
|
83
|
+
py -m pipx ensurepath
|
|
84
|
+
pipx install cutcaption
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Then restart your terminal if needed and run:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
cutcaption video.mp4
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Alternative: install with `pip`.
|
|
94
|
+
|
|
95
|
+
macOS/Linux:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
python3 -m pip install --user cutcaption
|
|
99
|
+
cutcaption video.mp4
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Windows:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
py -m pip install --user cutcaption
|
|
106
|
+
cutcaption video.mp4
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Requirements:
|
|
110
|
+
|
|
111
|
+
- Python 3.10+
|
|
112
|
+
- `ffmpeg` and `ffprobe` for burned-in captions and media probing
|
|
113
|
+
- faster-whisper model files download on first use
|
|
114
|
+
|
|
115
|
+
## Development Install
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
git clone https://github.com/your-org/cutcaption.git
|
|
119
|
+
cd cutcaption
|
|
120
|
+
pip install -e ".[dev]"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Run tests:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
python -m pytest
|
|
127
|
+
python -m ruff check .
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Usage
|
|
131
|
+
|
|
132
|
+
Caption one video:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
cutcaption video.mp4
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Choose an output folder:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
cutcaption video.mp4 --output ./out
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Caption a folder:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
cutcaption ./videos --output ./captioned
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Caption a folder recursively:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
cutcaption ./videos --recursive
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Export subtitles without rendering a video:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
cutcaption video.mp4 --srt --ass --no-burn
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Write JSON metadata:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
cutcaption video.mp4 --json
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Replace existing outputs:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
cutcaption video.mp4 --overwrite
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Preview planned jobs without transcription:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
cutcaption ./videos --dry-run
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Batch Examples
|
|
181
|
+
|
|
182
|
+
Fast batch captions for short-form clips:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
cutcaption ./clips --preset shorts --style pop --recursive
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Create only subtitle files for a batch:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
cutcaption ./clips --srt --ass --no-burn
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Skip files that already have requested outputs:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
cutcaption ./clips --skip-existing
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Force regeneration:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
cutcaption ./clips --overwrite
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`--jobs` is accepted for future parallel processing. Processing is currently sequential.
|
|
207
|
+
|
|
208
|
+
## Styles
|
|
209
|
+
|
|
210
|
+
List available styles:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
cutcaption styles
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Examples:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
cutcaption video.mp4 --style clean
|
|
220
|
+
cutcaption video.mp4 --style bold
|
|
221
|
+
cutcaption video.mp4 --style pop
|
|
222
|
+
cutcaption video.mp4 --style minimal
|
|
223
|
+
cutcaption video.mp4 --style boxed
|
|
224
|
+
cutcaption video.mp4 --style shorts
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Style guide:
|
|
228
|
+
|
|
229
|
+
- `clean`: readable white text, moderate outline, no box
|
|
230
|
+
- `bold`: larger uppercase captions with thicker outline
|
|
231
|
+
- `pop`: big creator-style uppercase captions with thick outline and shadow
|
|
232
|
+
- `minimal`: smaller captions with a thin outline
|
|
233
|
+
- `boxed`: readable text over a semi-transparent box
|
|
234
|
+
- `shorts`: one spoken word at a time for fast short-form videos
|
|
235
|
+
|
|
236
|
+
## Presets
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
cutcaption video.mp4 --preset shorts
|
|
240
|
+
cutcaption video.mp4 --preset youtube
|
|
241
|
+
cutcaption video.mp4 --preset podcast
|
|
242
|
+
cutcaption video.mp4 --preset default
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`shorts` is the default and is tuned for short creator videos.
|
|
246
|
+
|
|
247
|
+
## Config File
|
|
248
|
+
|
|
249
|
+
Create a starter config:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
cutcaption init
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Use a config file:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
cutcaption video.mp4 --config cutcaption.toml
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Example:
|
|
262
|
+
|
|
263
|
+
```toml
|
|
264
|
+
output = "captioned"
|
|
265
|
+
|
|
266
|
+
[transcription]
|
|
267
|
+
model = "small"
|
|
268
|
+
mode = "balanced"
|
|
269
|
+
language = "" # auto
|
|
270
|
+
device = "auto"
|
|
271
|
+
compute_type = "auto"
|
|
272
|
+
|
|
273
|
+
[caption]
|
|
274
|
+
preset = "shorts"
|
|
275
|
+
style = "pop"
|
|
276
|
+
max_words = 5
|
|
277
|
+
max_lines = 2
|
|
278
|
+
min_caption_duration = 0.25
|
|
279
|
+
max_caption_duration = 2.5
|
|
280
|
+
|
|
281
|
+
[render]
|
|
282
|
+
burn = true
|
|
283
|
+
srt = true
|
|
284
|
+
ass = false
|
|
285
|
+
json = true
|
|
286
|
+
|
|
287
|
+
[batch]
|
|
288
|
+
recursive = false
|
|
289
|
+
skip_existing = true
|
|
290
|
+
overwrite = false
|
|
291
|
+
jobs = 1
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
See [examples/cutcaption.toml](examples/cutcaption.toml).
|
|
295
|
+
|
|
296
|
+
## Doctor
|
|
297
|
+
|
|
298
|
+
Check local tools and dependencies:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
cutcaption doctor
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Use this first when rendering or transcription fails.
|
|
305
|
+
|
|
306
|
+
## Troubleshooting
|
|
307
|
+
|
|
308
|
+
### ffmpeg not found
|
|
309
|
+
|
|
310
|
+
Install ffmpeg and make sure `ffmpeg` and `ffprobe` are on your `PATH`.
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
# macOS
|
|
314
|
+
brew install ffmpeg
|
|
315
|
+
|
|
316
|
+
# Ubuntu/Debian
|
|
317
|
+
sudo apt install ffmpeg
|
|
318
|
+
|
|
319
|
+
# Windows
|
|
320
|
+
winget install Gyan.FFmpeg
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Then run:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
cutcaption doctor
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Model download is slow
|
|
330
|
+
|
|
331
|
+
faster-whisper downloads the selected model on first use. The first run can take longer depending on model size and network speed. Use a smaller model for quicker startup:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
cutcaption video.mp4 --model small --mode fast
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### CUDA is not working
|
|
338
|
+
|
|
339
|
+
CPU transcription works by default. If CUDA setup is unreliable, use the default device or force CPU in your config:
|
|
340
|
+
|
|
341
|
+
```toml
|
|
342
|
+
[transcription]
|
|
343
|
+
device = "cpu"
|
|
344
|
+
compute_type = "int8"
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
Run:
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
cutcaption doctor
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Output already exists
|
|
354
|
+
|
|
355
|
+
By default, cutcaption skips existing requested outputs in batch mode. To regenerate files:
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
cutcaption video.mp4 --overwrite
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
To fail instead of skipping existing files:
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
cutcaption video.mp4 --no-skip-existing
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## Roadmap
|
|
368
|
+
|
|
369
|
+
- Parallel batch processing
|
|
370
|
+
- Live style preview
|
|
371
|
+
- More caption animation presets
|
|
372
|
+
- Current-word highlighting
|
|
373
|
+
- GPU setup helpers
|
|
374
|
+
- More export formats
|
|
375
|
+
|
|
376
|
+
## Contributing
|
|
377
|
+
|
|
378
|
+
Contributions are welcome. For local work:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
pip install -e ".[dev]"
|
|
382
|
+
python -m pytest
|
|
383
|
+
python -m ruff check .
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Keep changes focused, add tests for behavior changes, and update docs when user-facing commands or config options change.
|
|
387
|
+
|
|
388
|
+
## License
|
|
389
|
+
|
|
390
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cutcaption/__init__.py,sha256=Hcbc55V5t6S1l0pdapFzz4EBj24Hc4aDBWzFETyofc8,118
|
|
2
|
+
cutcaption/__main__.py,sha256=Frh48zMdraFVWMe5Nj7oPi1WCAlTZS7vLKG0x-KxUco,126
|
|
3
|
+
cutcaption/_version.py,sha256=V2LDU1g_DxSsLV-UGpg3C4Rl5TRVZdR-dDciLlw7tBA,78
|
|
4
|
+
cutcaption/chunking.py,sha256=LtQAANdTW90yZ6fTlO-jGTzTgBh7a8F-m7J8Sux4VbY,7319
|
|
5
|
+
cutcaption/cli.py,sha256=ArOS0dnkSNzWT7wW0prrTkUCHnp8oSQghtS5s69NJGE,10455
|
|
6
|
+
cutcaption/config.py,sha256=Awh9EWRBwt7C4042a-heDmdsfccbv79iJq9-53tvjtM,8626
|
|
7
|
+
cutcaption/doctor.py,sha256=MTN3PeZcoI53gjDjYRvW8CrE-rrYzOV4RrrgKIpdJ5w,4461
|
|
8
|
+
cutcaption/media.py,sha256=_KhDGcl3mUgD-d1zaviwkCSGgQSRupmpHxbzODRJUJI,490
|
|
9
|
+
cutcaption/models.py,sha256=AF1VP60kpTg1Dr_5hqOmV69e1vicxXTNbw_944NCfL4,1950
|
|
10
|
+
cutcaption/pipeline.py,sha256=sOqUHwyQkqWpz3x1X1TnbrB_3wVLj0LefCPUpeS-Vi0,5224
|
|
11
|
+
cutcaption/render.py,sha256=6Ykzf4qNXdpy_0g6o7OdnRQMZbf7XE7ufi-clEOVex8,1906
|
|
12
|
+
cutcaption/styles.py,sha256=8nzU3orpc5DDp9eh4mXBUdp9GEEMgEJYnKbIfQm-52o,3747
|
|
13
|
+
cutcaption/transcribe.py,sha256=F28lZDtQYx9PXOEcwjp5IkByn1gOd05rmaYT4v-R0Vk,4085
|
|
14
|
+
cutcaption/exporters/__init__.py,sha256=d63PKR8_9crKXkaWPNaXVLtGjD9GmUAyOuQLGN3jl2Y,39
|
|
15
|
+
cutcaption/exporters/ass.py,sha256=t50nq2jyJH7HATs9fIlTICVObBIRqwnQZ3WQTFbaOxc,3308
|
|
16
|
+
cutcaption/exporters/json.py,sha256=FbH8xDxGHKmO-bg7-NWgESJbbiCBaDqrsPGWRN9766c,2001
|
|
17
|
+
cutcaption/exporters/srt.py,sha256=B95RxdAHSeNqu4vmC74Xc3BuayhP9Ma1NE-sMsRn4Qs,1617
|
|
18
|
+
cutcaption/utils/__init__.py,sha256=vTzpzAhwZwhp9xdzSN95SWmf02qgw7Asc0ULXG4aEok,23
|
|
19
|
+
cutcaption/utils/ffmpeg.py,sha256=OZdzgW-D9WavPOwtDmwS0PR0q0M5Hq0NgWsumOGEh2s,4055
|
|
20
|
+
cutcaption/utils/logging.py,sha256=mUEx9Gn0RqvM3Jw2FiTCXPN-vHlYSvVRJwRpSE7wge4,122
|
|
21
|
+
cutcaption/utils/paths.py,sha256=cR1Ja0eZkDBksxyPwJNVAmZVGNSkIvhIvu4-2umCNFA,2725
|
|
22
|
+
cutcaption-0.1.0.dist-info/licenses/LICENSE,sha256=nx6Rd7E44-cujPINBOFMd3oLVC1QNqypv0qnhAiq7NQ,1080
|
|
23
|
+
cutcaption-0.1.0.dist-info/METADATA,sha256=JcXoRDrb_JdxeNvFSVx1sckdfldgwvbIMB4SZ2-YDNo,7136
|
|
24
|
+
cutcaption-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
25
|
+
cutcaption-0.1.0.dist-info/entry_points.txt,sha256=IUiZwDpsc-F8RpZBPV1z1g0_1Naskshhi1opWsX4rlk,51
|
|
26
|
+
cutcaption-0.1.0.dist-info/top_level.txt,sha256=Tm8_ifv7vmrLJG-EtcMu8TNjEDEzP7UgJAzgw0YEM2k,11
|
|
27
|
+
cutcaption-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cutcaption contributors
|
|
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.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cutcaption
|