@clipen/clipen-cli 1.0.0 → 1.0.2
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.
- package/README.md +56 -48
- package/apps/web/dist/assets/{index-D5D2HiB1.js → index-DPHwA954.js} +1 -1
- package/apps/web/dist/index.html +1 -1
- package/bin/clipen.js +1 -1
- package/package.json +7 -6
- package/pyproject.toml +18 -2
- package/requirements/dev.txt +2 -0
- package/src/clipen/__init__.py +1 -1
- package/src/clipen/analysis/__init__.py +7 -7
- package/src/clipen/analysis/artifacts.py +4 -10
- package/src/clipen/analysis/audio.py +10 -8
- package/src/clipen/analysis/evidence_service.py +345 -167
- package/src/clipen/analysis/image_similarity.py +5 -14
- package/src/clipen/analysis/keyframes.py +5 -17
- package/src/clipen/analysis/models.py +5 -7
- package/src/clipen/analysis/qwen_worker.py +19 -54
- package/src/clipen/analysis/resources.py +2 -1
- package/src/clipen/analysis/runtime.py +1 -3
- package/src/clipen/analysis/service.py +16 -48
- package/src/clipen/analysis/setup.py +11 -25
- package/src/clipen/analysis/setup_cli.py +5 -15
- package/src/clipen/analysis/storage.py +96 -278
- package/src/clipen/analysis/transcription.py +40 -82
- package/src/clipen/analysis/visual.py +109 -48
- package/src/clipen/annotations/__init__.py +5 -2
- package/src/clipen/annotations/models.py +1 -1
- package/src/clipen/annotations/storage.py +132 -84
- package/src/clipen/annotations/suggestions.py +3 -8
- package/src/clipen/asr_release.py +4 -11
- package/src/clipen/bootstrap.py +71 -61
- package/src/clipen/{planning/models.py → candidates.py} +29 -47
- package/src/clipen/cli.py +4 -9
- package/src/clipen/controller/app.py +401 -214
- package/src/clipen/controller/server.py +28 -38
- package/src/clipen/domain/__init__.py +1 -1
- package/src/clipen/domain/media_time.py +3 -10
- package/src/clipen/domain/timeline.py +45 -47
- package/src/clipen/domain/validation.py +0 -1
- package/src/clipen/editing/__init__.py +1 -1
- package/src/clipen/editing/agent_models.py +4 -11
- package/src/clipen/editing/agent_repository.py +393 -172
- package/src/clipen/editing/agent_tools.py +180 -99
- package/src/clipen/editing/alignment.py +92 -52
- package/src/clipen/editing/alignment_setup.py +118 -70
- package/src/clipen/editing/alignment_worker.py +11 -9
- package/src/clipen/editing/change_report.py +95 -38
- package/src/clipen/editing/compiler.py +0 -1
- package/src/clipen/editing/component_looks.py +58 -34
- package/src/clipen/editing/component_review.py +34 -38
- package/src/clipen/editing/coordinator.py +213 -92
- package/src/clipen/editing/editorial_review.py +217 -95
- package/src/clipen/editing/evidence_jobs.py +457 -200
- package/src/clipen/editing/history_changes.py +129 -68
- package/src/clipen/editing/music_choices.py +8 -5
- package/src/clipen/editing/production_catalog.py +573 -136
- package/src/clipen/editing/production_limits.py +43 -17
- package/src/clipen/editing/production_media.py +376 -167
- package/src/clipen/editing/production_preview.py +322 -129
- package/src/clipen/editing/production_progress.py +164 -69
- package/src/clipen/editing/production_requirements.py +106 -39
- package/src/clipen/editing/production_tools.py +1064 -462
- package/src/clipen/editing/program_audio.py +211 -81
- package/src/clipen/editing/program_direction.py +59 -25
- package/src/clipen/editing/program_story.py +83 -45
- package/src/clipen/editing/program_subtitles.py +194 -96
- package/src/clipen/editing/programme_review.py +98 -50
- package/src/clipen/editing/prompt_history.py +64 -27
- package/src/clipen/editing/recut.py +65 -25
- package/src/clipen/editing/refinement_references.py +176 -86
- package/src/clipen/editing/resolve_export.py +449 -218
- package/src/clipen/editing/resolve_titles.py +162 -105
- package/src/clipen/editing/skill_tools.py +530 -154
- package/src/clipen/editing/source_dialogue.py +177 -67
- package/src/clipen/editing/speech_coverage.py +42 -22
- package/src/clipen/editing/speech_quality.py +6 -1
- package/src/clipen/editing/tool_receipts.py +78 -32
- package/src/clipen/editing/versions.py +122 -64
- package/src/clipen/editing/visual_preview.py +157 -61
- package/src/clipen/editing/workbench.py +104 -42
- package/src/clipen/finishing/audio.py +69 -30
- package/src/clipen/finishing/catalog.py +176 -93
- package/src/clipen/finishing/models.py +1 -1
- package/src/clipen/finishing/renderer.py +33 -14
- package/src/clipen/mcp_editing/__main__.py +3 -1
- package/src/clipen/mcp_editing/server.py +77 -34
- package/src/clipen/media/__init__.py +3 -3
- package/src/clipen/media/discovery.py +7 -20
- package/src/clipen/media/models.py +7 -18
- package/src/clipen/media/preview.py +14 -24
- package/src/clipen/media/probe.py +16 -44
- package/src/clipen/media/service.py +6 -19
- package/src/clipen/media/storage.py +33 -81
- package/src/clipen/music_vocabulary.py +33 -4
- package/src/clipen/power.py +8 -3
- package/src/clipen/projects/__init__.py +1 -1
- package/src/clipen/projects/deletion.py +19 -32
- package/src/clipen/projects/finishing_schema.py +3 -1
- package/src/clipen/projects/models.py +2 -5
- package/src/clipen/projects/picker.py +13 -37
- package/src/clipen/projects/service.py +8 -24
- package/src/clipen/projects/storage.py +226 -246
- package/src/clipen/provider_registry.py +9 -20
- package/src/clipen/providers/account.py +86 -35
- package/src/clipen/providers/claude.py +59 -25
- package/src/clipen/providers/claude_editing.py +14 -7
- package/src/clipen/providers/codex.py +73 -118
- package/src/clipen/providers/codex_editing.py +2 -2
- package/src/clipen/providers/editing_agent.py +19 -17
- package/src/clipen/providers/recovery.py +7 -8
- package/src/clipen/rendering/cover.py +18 -5
- package/src/clipen/rendering/custom_components.py +167 -79
- package/src/clipen/rendering/custom_render.py +62 -41
- package/src/clipen/rendering/production_effects.py +77 -45
- package/src/clipen/rendering/program_components.py +134 -73
- package/src/clipen/rendering/program_creator.py +432 -277
- package/src/clipen/rendering/program_identities.py +277 -182
- package/src/clipen/rendering/program_motion.py +140 -95
- package/src/clipen/rendering/program_studio.py +175 -116
- package/src/clipen/rendering/program_styles.py +231 -145
- package/src/clipen/rendering/program_subtitles.py +71 -34
- package/src/clipen/rendering/renderer.py +150 -121
- package/src/clipen/rendering/storage.py +9 -22
- package/src/clipen/rendering/titles.py +193 -86
- package/src/clipen/skills/__init__.py +1 -0
- package/src/clipen/skills/catalog.py +151 -55
- package/src/clipen/skills/library.py +13 -7
- package/src/clipen/skills/package.py +46 -23
- package/src/clipen/skills/visual_styles.py +29 -18
- package/src/clipen/workspace.py +15 -44
- package/install +0 -25
- package/src/clipen/planning/__init__.py +0 -9
- package/uninstall +0 -25
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from dataclasses import dataclass
|
|
6
5
|
import os
|
|
7
6
|
import re
|
|
8
|
-
from pathlib import Path
|
|
9
7
|
import subprocess
|
|
10
8
|
import tempfile
|
|
11
9
|
import threading
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from pathlib import Path
|
|
12
12
|
from typing import Callable, Iterable
|
|
13
13
|
|
|
14
14
|
from clipen.domain import EditTimeline, TextClip, TrackKind
|
|
@@ -37,16 +37,11 @@ class TitleCardRenderer:
|
|
|
37
37
|
# memory pressure on consumer machines.
|
|
38
38
|
_MAX_TITLES = 32
|
|
39
39
|
|
|
40
|
-
def __init__(self,custom_styles=None):
|
|
41
|
-
self.custom_styles=custom_styles or {}
|
|
40
|
+
def __init__(self, custom_styles=None):
|
|
41
|
+
self.custom_styles = custom_styles or {}
|
|
42
42
|
|
|
43
43
|
def render(self, timeline: EditTimeline, directory: Path) -> tuple[RenderedTitle, ...]:
|
|
44
|
-
items = tuple(
|
|
45
|
-
item
|
|
46
|
-
for track in timeline.tracks
|
|
47
|
-
if track.kind is TrackKind.TITLE
|
|
48
|
-
for item in track.items
|
|
49
|
-
)
|
|
44
|
+
items = tuple(item for track in timeline.tracks if track.kind is TrackKind.TITLE for item in track.items)
|
|
50
45
|
if len(items) > self._MAX_TITLES:
|
|
51
46
|
raise TitleRenderError("preview_title_limit_exceeded")
|
|
52
47
|
if not items:
|
|
@@ -95,29 +90,42 @@ class TitleCardRenderer:
|
|
|
95
90
|
self, draw, image_font, font_path: Path, timeline: EditTimeline, item: TextClip, relative_frame=None
|
|
96
91
|
) -> None:
|
|
97
92
|
width, height = timeline.width, timeline.height
|
|
98
|
-
if self.custom_styles.get(item.style_id,{}).get(
|
|
93
|
+
if self.custom_styles.get(item.style_id, {}).get("kind") == "program_component":
|
|
99
94
|
from .program_components import draw_program_component
|
|
100
|
-
|
|
95
|
+
|
|
96
|
+
draw_program_component(draw, font_path, timeline, item, self.custom_styles[item.style_id], relative_frame)
|
|
101
97
|
return
|
|
102
|
-
if self.custom_styles.get(item.style_id,{}).get(
|
|
98
|
+
if self.custom_styles.get(item.style_id, {}).get("kind") == "program_subtitle":
|
|
103
99
|
from .program_subtitles import draw_program_subtitle
|
|
104
|
-
|
|
100
|
+
|
|
101
|
+
draw_program_subtitle(draw, font_path, timeline, item, self.custom_styles[item.style_id], relative_frame)
|
|
105
102
|
return
|
|
106
103
|
if item.style_id in self.custom_styles:
|
|
107
|
-
profile=self.custom_styles[item.style_id]
|
|
108
|
-
size=max(1,round(height*profile[
|
|
109
|
-
font=image_font.truetype(str(font_path),size)
|
|
110
|
-
maximum=round(width*profile[
|
|
111
|
-
lines=self._wrap(draw,item.text,font,maximum)
|
|
112
|
-
line_height=max(1,round(size*1.5))
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
profile = self.custom_styles[item.style_id]
|
|
105
|
+
size = max(1, round(height * profile["font_size_ratio"]))
|
|
106
|
+
font = image_font.truetype(str(font_path), size)
|
|
107
|
+
maximum = round(width * profile["width_ratio"])
|
|
108
|
+
lines = self._wrap(draw, item.text, font, maximum)
|
|
109
|
+
line_height = max(1, round(size * 1.5))
|
|
110
|
+
pad = max(1, round(size * 0.25))
|
|
111
|
+
x = round(width * profile["x"])
|
|
112
|
+
y = round(height * profile["y"])
|
|
113
|
+
if y + line_height * len(lines) + pad > height or x + maximum > width:
|
|
114
|
+
raise TitleRenderError("preview_text_overflow")
|
|
116
115
|
for row in lines:
|
|
117
|
-
length=draw.textlength(row,font=font)
|
|
118
|
-
at=
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
length = draw.textlength(row, font=font)
|
|
117
|
+
at = (
|
|
118
|
+
x
|
|
119
|
+
if profile["align"] == "left"
|
|
120
|
+
else x + (maximum - length) / (2 if profile["align"] == "center" else 1)
|
|
121
|
+
)
|
|
122
|
+
draw.rounded_rectangle(
|
|
123
|
+
(at - pad, y - pad, at + length + pad, y + line_height),
|
|
124
|
+
radius=pad,
|
|
125
|
+
fill=tuple(profile["background_color"]),
|
|
126
|
+
)
|
|
127
|
+
draw.text((at, y), row, font=font, fill=tuple(profile["text_color"]))
|
|
128
|
+
y += line_height
|
|
121
129
|
return
|
|
122
130
|
if item.style_id == "title.chapter":
|
|
123
131
|
size = max(28, round(height * 0.055))
|
|
@@ -193,9 +201,7 @@ class TitleCardRenderer:
|
|
|
193
201
|
@staticmethod
|
|
194
202
|
def _text_box(draw, lines: Iterable[str], font, spacing: int) -> tuple[int, int]:
|
|
195
203
|
boxes = [draw.textbbox((0, 0), line, font=font) for line in lines]
|
|
196
|
-
return max(box[2] - box[0] for box in boxes), sum(
|
|
197
|
-
box[3] - box[1] for box in boxes
|
|
198
|
-
) + spacing * (len(boxes) - 1)
|
|
204
|
+
return max(box[2] - box[0] for box in boxes), sum(box[3] - box[1] for box in boxes) + spacing * (len(boxes) - 1)
|
|
199
205
|
|
|
200
206
|
@staticmethod
|
|
201
207
|
def _multiline(draw, origin, lines: Iterable[str], font, fill, font_size: int) -> None:
|
|
@@ -236,9 +242,7 @@ class FfmpegTitleCompositor:
|
|
|
236
242
|
filters = []
|
|
237
243
|
previous = "[0:v]"
|
|
238
244
|
for index, title in enumerate(titles, start=1):
|
|
239
|
-
command.extend(
|
|
240
|
-
["-loop", "1", "-t", f"{title.duration_seconds:.6f}", "-i", str(title.path)]
|
|
241
|
-
)
|
|
245
|
+
command.extend(["-loop", "1", "-t", f"{title.duration_seconds:.6f}", "-i", str(title.path)])
|
|
242
246
|
fade = min(0.18, title.duration_seconds / 4)
|
|
243
247
|
fade_out = max(0.0, title.duration_seconds - fade)
|
|
244
248
|
filters.append(
|
|
@@ -247,22 +251,30 @@ class FfmpegTitleCompositor:
|
|
|
247
251
|
f"setpts=PTS+{title.start_seconds:.6f}/TB[title{index}]"
|
|
248
252
|
)
|
|
249
253
|
output_label = f"composed{index}"
|
|
250
|
-
filters.append(
|
|
251
|
-
f"{previous}[title{index}]overlay=0:0:eof_action=pass:shortest=0[{output_label}]"
|
|
252
|
-
)
|
|
254
|
+
filters.append(f"{previous}[title{index}]overlay=0:0:eof_action=pass:shortest=0[{output_label}]")
|
|
253
255
|
previous = f"[{output_label}]"
|
|
254
256
|
command.extend(
|
|
255
257
|
[
|
|
256
|
-
"-filter_complex",
|
|
257
|
-
"
|
|
258
|
-
"-map",
|
|
259
|
-
|
|
260
|
-
"-
|
|
261
|
-
"
|
|
262
|
-
"-
|
|
263
|
-
"
|
|
264
|
-
"-
|
|
265
|
-
"
|
|
258
|
+
"-filter_complex",
|
|
259
|
+
";".join(filters),
|
|
260
|
+
"-map",
|
|
261
|
+
previous,
|
|
262
|
+
"-map",
|
|
263
|
+
"0:a?",
|
|
264
|
+
"-c:v",
|
|
265
|
+
"libx264",
|
|
266
|
+
"-preset",
|
|
267
|
+
"veryfast",
|
|
268
|
+
"-crf",
|
|
269
|
+
"21",
|
|
270
|
+
"-pix_fmt",
|
|
271
|
+
"yuv420p",
|
|
272
|
+
"-c:a",
|
|
273
|
+
"copy",
|
|
274
|
+
"-movflags",
|
|
275
|
+
"+faststart",
|
|
276
|
+
"-progress",
|
|
277
|
+
"pipe:1",
|
|
266
278
|
"-nostats",
|
|
267
279
|
str(output),
|
|
268
280
|
]
|
|
@@ -297,64 +309,159 @@ class FfmpegTitleCompositor:
|
|
|
297
309
|
progress(1.0)
|
|
298
310
|
|
|
299
311
|
|
|
300
|
-
def compose_dense_titles(
|
|
312
|
+
def compose_dense_titles(
|
|
313
|
+
executable, source, timeline, directory, output, cancel, custom_styles=None, progress=None, hardware=False
|
|
314
|
+
):
|
|
301
315
|
"""One event-based RGBA stream avoids opening dozens of full-HD inputs.
|
|
302
316
|
|
|
303
317
|
Reports progress while drawing (first 40%) and while FFmpeg overlays the
|
|
304
318
|
stream (the rest), so a long film never looks stuck at the same number.
|
|
305
319
|
"""
|
|
306
|
-
report=progress or (lambda _value:None)
|
|
307
|
-
from PIL import Image,ImageDraw,ImageFont
|
|
320
|
+
report = progress or (lambda _value: None)
|
|
321
|
+
from PIL import Image, ImageDraw, ImageFont
|
|
322
|
+
|
|
308
323
|
from clipen.finishing.audio import run_process
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
324
|
+
|
|
325
|
+
items = [i for t in timeline.tracks if t.kind is TrackKind.TITLE for i in t.items]
|
|
326
|
+
if len(items) > (960 if timeline.production_session_id else 96):
|
|
327
|
+
raise TitleRenderError("preview_title_limit_exceeded")
|
|
328
|
+
font = TitleCardRenderer._font_path()
|
|
329
|
+
if font is None:
|
|
330
|
+
raise TitleRenderError("preview_title_font_missing")
|
|
331
|
+
renderer = TitleCardRenderer(custom_styles)
|
|
332
|
+
fps = timeline.frame_rate.numerator / timeline.frame_rate.denominator
|
|
333
|
+
boundaries = sorted(
|
|
334
|
+
{
|
|
335
|
+
0,
|
|
336
|
+
timeline.duration_frames,
|
|
337
|
+
*(i.start_frame for i in items),
|
|
338
|
+
*(i.start_frame + i.duration_frames for i in items),
|
|
339
|
+
}
|
|
340
|
+
)
|
|
315
341
|
from .program_subtitles import animation_boundaries
|
|
316
|
-
|
|
342
|
+
|
|
343
|
+
boundaries = sorted(
|
|
344
|
+
set(boundaries)
|
|
345
|
+
| {
|
|
346
|
+
b
|
|
347
|
+
for i in items
|
|
348
|
+
if (custom_styles or {}).get(i.style_id, {}).get("kind") == "program_subtitle"
|
|
349
|
+
for b in animation_boundaries(i)
|
|
350
|
+
}
|
|
351
|
+
)
|
|
317
352
|
from .program_components import animation_boundaries as component_boundaries
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
353
|
+
|
|
354
|
+
boundaries = sorted(
|
|
355
|
+
set(boundaries)
|
|
356
|
+
| {
|
|
357
|
+
b
|
|
358
|
+
for i in items
|
|
359
|
+
if (custom_styles or {}).get(i.style_id, {}).get("kind") == "program_component"
|
|
360
|
+
for b in component_boundaries(i, custom_styles[i.style_id], timeline)
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
lines = ["ffconcat version 1.0"]
|
|
364
|
+
events = max(1, len(boundaries) - 1)
|
|
365
|
+
for index, (start, end) in enumerate(zip(boundaries, boundaries[1:])):
|
|
366
|
+
if cancel.is_set():
|
|
367
|
+
raise TitleRenderError("cancelled")
|
|
368
|
+
if index % 20 == 0:
|
|
369
|
+
report(0.4 * index / events)
|
|
370
|
+
image = Image.new("RGBA", (timeline.width, timeline.height), (0, 0, 0, 0))
|
|
371
|
+
draw = ImageDraw.Draw(image)
|
|
325
372
|
for item in items:
|
|
326
|
-
if item.start_frame<=start<item.start_frame+item.duration_frames:
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
373
|
+
if item.start_frame <= start < item.start_frame + item.duration_frames:
|
|
374
|
+
renderer._draw_card(draw, ImageFont, font, timeline, item, start - item.start_frame)
|
|
375
|
+
name = f"text-event-{index}.png"
|
|
376
|
+
image.save(directory / name)
|
|
377
|
+
lines.extend(
|
|
378
|
+
(
|
|
379
|
+
f"file '{name}'",
|
|
380
|
+
f"option framerate {timeline.frame_rate.numerator}/{timeline.frame_rate.denominator}",
|
|
381
|
+
f"duration {(end - start) / fps:.9f}",
|
|
382
|
+
)
|
|
383
|
+
)
|
|
384
|
+
lines.extend(
|
|
385
|
+
(
|
|
386
|
+
f"file 'text-event-{len(boundaries) - 2}.png'",
|
|
387
|
+
f"option framerate {timeline.frame_rate.numerator}/{timeline.frame_rate.denominator}",
|
|
388
|
+
)
|
|
389
|
+
)
|
|
390
|
+
manifest = directory / "text-events.ffconcat"
|
|
391
|
+
manifest.write_text("\n".join(lines) + "\n")
|
|
392
|
+
report(0.4)
|
|
393
|
+
seconds = timeline.duration_frames / fps
|
|
394
|
+
progress_file = directory / "overlay-progress.txt"
|
|
395
|
+
done = threading.Event()
|
|
396
|
+
|
|
334
397
|
def watch():
|
|
335
398
|
# FFmpeg rewrites out_time_us in its progress file about twice a second.
|
|
336
|
-
while not done.wait(.5):
|
|
337
|
-
try:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
399
|
+
while not done.wait(0.5):
|
|
400
|
+
try:
|
|
401
|
+
text = progress_file.read_text()
|
|
402
|
+
except OSError:
|
|
403
|
+
continue
|
|
404
|
+
times = [int(v) for v in re.findall(r"out_time_us=(\d+)", text)]
|
|
405
|
+
if times and seconds > 0:
|
|
406
|
+
report(0.4 + 0.6 * min(1.0, times[-1] / 1e6 / seconds))
|
|
407
|
+
|
|
408
|
+
watcher = threading.Thread(target=watch, daemon=True)
|
|
409
|
+
watcher.start()
|
|
410
|
+
|
|
342
411
|
def encode(video):
|
|
343
|
-
run_process(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
412
|
+
run_process(
|
|
413
|
+
[
|
|
414
|
+
executable,
|
|
415
|
+
"-v",
|
|
416
|
+
"error",
|
|
417
|
+
"-nostdin",
|
|
418
|
+
"-y",
|
|
419
|
+
"-progress",
|
|
420
|
+
str(progress_file),
|
|
421
|
+
"-filter_complex_threads",
|
|
422
|
+
"2",
|
|
423
|
+
"-i",
|
|
424
|
+
str(source),
|
|
425
|
+
"-f",
|
|
426
|
+
"concat",
|
|
427
|
+
"-safe",
|
|
428
|
+
"0",
|
|
429
|
+
"-i",
|
|
430
|
+
str(manifest),
|
|
431
|
+
"-filter_complex",
|
|
432
|
+
"[0:v][1:v]overlay=eof_action=repeat:format=auto,format=yuv420p[v]",
|
|
433
|
+
"-map",
|
|
434
|
+
"[v]",
|
|
435
|
+
"-map",
|
|
436
|
+
"0:a?",
|
|
437
|
+
"-t",
|
|
438
|
+
str(timeline.duration_frames / fps),
|
|
439
|
+
"-r",
|
|
440
|
+
f"{timeline.frame_rate.numerator}/{timeline.frame_rate.denominator}",
|
|
441
|
+
*video,
|
|
442
|
+
"-c:a",
|
|
443
|
+
"copy",
|
|
444
|
+
"-movflags",
|
|
445
|
+
"+faststart",
|
|
446
|
+
str(output),
|
|
447
|
+
],
|
|
448
|
+
cancel,
|
|
449
|
+
timeout=max(300, round(timeline.duration_frames / fps * 3)),
|
|
450
|
+
)
|
|
451
|
+
|
|
452
|
+
software = ["-c:v", "libx264", "-preset", "veryfast", "-crf", "21"]
|
|
348
453
|
try:
|
|
349
454
|
if not hardware:
|
|
350
455
|
encode(software)
|
|
351
456
|
else:
|
|
352
457
|
# The Mac's video encoder is about a third faster; any machine that refuses it gets the software path.
|
|
353
458
|
try:
|
|
354
|
-
encode([
|
|
459
|
+
encode(["-c:v", "h264_videotoolbox", "-b:v", "8000k"])
|
|
355
460
|
except Exception:
|
|
356
|
-
if cancel.is_set():
|
|
461
|
+
if cancel.is_set():
|
|
462
|
+
raise
|
|
357
463
|
encode(software)
|
|
358
464
|
finally:
|
|
359
|
-
done.set()
|
|
360
|
-
|
|
465
|
+
done.set()
|
|
466
|
+
watcher.join(timeout=2)
|
|
467
|
+
report(1.0)
|