@auscera/cleoedits 0.0.0-stage → 0.1.0

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.
Files changed (230) hide show
  1. package/README.md +62 -2
  2. package/cli.mjs +149 -0
  3. package/lib/dependencies.mjs +384 -0
  4. package/lib/run.mjs +114 -0
  5. package/lib/workspace.mjs +167 -0
  6. package/package.json +240 -3
  7. package/workspace/.agents/skills/cleoedits/SKILL.md +29 -0
  8. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/audiogram.json +41 -0
  9. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/facebook.json +48 -0
  10. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/linkedin.json +48 -0
  11. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/podcast.json +23 -0
  12. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/reels.json +48 -0
  13. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/shorts.json +48 -0
  14. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/tiktok.json +48 -0
  15. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/x.json +48 -0
  16. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube-shorts.json +48 -0
  17. package/workspace/.agents/skills/cleoedits/assets/ffmpeg_templates/youtube.json +48 -0
  18. package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/LICENSE-SimpleIcons +30 -0
  19. package/workspace/.agents/skills/cleoedits/assets/reel_effects/assets/logos.json +1 -0
  20. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Anton-Regular.ttf +0 -0
  21. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/ArchivoBlack-Regular.ttf +0 -0
  22. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/InstrumentSerif-Italic.ttf +0 -0
  23. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Inter.ttf +0 -0
  24. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/LICENSE-PermanentMarker.txt +202 -0
  25. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Montserrat.ttf +0 -0
  26. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Anton.txt +93 -0
  27. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-ArchivoBlack.txt +93 -0
  28. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-InstrumentSerif.txt +93 -0
  29. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Inter.txt +93 -0
  30. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Montserrat.txt +93 -0
  31. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-PlayfairDisplay.txt +93 -0
  32. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-Poppins.txt +93 -0
  33. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/OFL-SpaceMono.txt +93 -0
  34. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PermanentMarker-Regular.ttf +0 -0
  35. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay-Italic.ttf +0 -0
  36. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/PlayfairDisplay.ttf +0 -0
  37. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Black.ttf +0 -0
  38. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-Bold.ttf +0 -0
  39. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/Poppins-ExtraBold.ttf +0 -0
  40. package/workspace/.agents/skills/cleoedits/assets/reel_effects/fonts/SpaceMono-Bold.ttf +0 -0
  41. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-MediaPipe +218 -0
  42. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/LICENSE-YuNet +21 -0
  43. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/NOTICE.md +4 -0
  44. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/selfie_segmenter.tflite +0 -0
  45. package/workspace/.agents/skills/cleoedits/assets/reel_effects/models/yunet.onnx +0 -0
  46. package/workspace/.agents/skills/cleoedits/assets/video_styles/LICENSE +21 -0
  47. package/workspace/.agents/skills/cleoedits/assets/video_styles/audio-app-ui/STYLE.md +65 -0
  48. package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/STYLE.md +53 -0
  49. package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/index.html +328 -0
  50. package/workspace/.agents/skills/cleoedits/assets/video_styles/blueprint/studio.js +57 -0
  51. package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/STYLE.md +65 -0
  52. package/workspace/.agents/skills/cleoedits/assets/video_styles/data-story/index.html +575 -0
  53. package/workspace/.agents/skills/cleoedits/assets/video_styles/design-app-ui/STYLE.md +68 -0
  54. package/workspace/.agents/skills/cleoedits/assets/video_styles/editor-ui/STYLE.md +73 -0
  55. package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/STYLE.md +54 -0
  56. package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/index.html +189 -0
  57. package/workspace/.agents/skills/cleoedits/assets/video_styles/editorial-paper/studio.js +57 -0
  58. package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/STYLE.md +64 -0
  59. package/workspace/.agents/skills/cleoedits/assets/video_styles/explainer-diagram/index.html +620 -0
  60. package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/STYLE.md +55 -0
  61. package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/index.html +238 -0
  62. package/workspace/.agents/skills/cleoedits/assets/video_styles/graphite-ui/studio.js +57 -0
  63. package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/STYLE.md +66 -0
  64. package/workspace/.agents/skills/cleoedits/assets/video_styles/growing-city/index.html +602 -0
  65. package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/STYLE.md +66 -0
  66. package/workspace/.agents/skills/cleoedits/assets/video_styles/ink-line/index.html +777 -0
  67. package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/STYLE.md +56 -0
  68. package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/index.html +186 -0
  69. package/workspace/.agents/skills/cleoedits/assets/video_styles/midnight-grid/studio.js +57 -0
  70. package/workspace/.agents/skills/cleoedits/assets/video_styles/motion-app-ui/STYLE.md +68 -0
  71. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/STYLE.md +56 -0
  72. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/index.html +244 -0
  73. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-cut/studio.js +57 -0
  74. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/STYLE.md +67 -0
  75. package/workspace/.agents/skills/cleoedits/assets/video_styles/paper-world/index.html +663 -0
  76. package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/STYLE.md +59 -0
  77. package/workspace/.agents/skills/cleoedits/assets/video_styles/particle-field/index.html +395 -0
  78. package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/STYLE.md +52 -0
  79. package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/index.html +194 -0
  80. package/workspace/.agents/skills/cleoedits/assets/video_styles/poster-pop/studio.js +57 -0
  81. package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/STYLE.md +58 -0
  82. package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/index.html +242 -0
  83. package/workspace/.agents/skills/cleoedits/assets/video_styles/risograph/studio.js +57 -0
  84. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/STYLE.md +53 -0
  85. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/index.html +138 -0
  86. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-grid/studio.js +57 -0
  87. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/STYLE.md +63 -0
  88. package/workspace/.agents/skills/cleoedits/assets/video_styles/swiss-kinetic/index.html +599 -0
  89. package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/STYLE.md +65 -0
  90. package/workspace/.agents/skills/cleoedits/assets/video_styles/time-travel/index.html +1297 -0
  91. package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/STYLE.md +69 -0
  92. package/workspace/.agents/skills/cleoedits/assets/video_styles/weather-widget/index.html +674 -0
  93. package/workspace/.agents/skills/cleoedits/references/audio-clearervoice-elevenlabs.md +11 -0
  94. package/workspace/.agents/skills/cleoedits/references/ffmpeg-and-reels.md +15 -0
  95. package/workspace/.agents/skills/cleoedits/references/hyperframes-workflows.md +13 -0
  96. package/workspace/.agents/skills/cleoedits/references/kdenlive-cli-and-mcp.md +12 -0
  97. package/workspace/.agents/skills/cleoedits/references/motion-design-pipeline.md +7 -0
  98. package/workspace/.agents/skills/cleoedits/references/motion-taste-emil.md +5 -0
  99. package/workspace/.agents/skills/cleoedits/references/playwright-demo-capture.md +9 -0
  100. package/workspace/.agents/skills/cleoedits/references/remotion-workflows.md +13 -0
  101. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/LICENSE +21 -0
  102. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_ass_overlay.py +399 -0
  103. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/__init__.py +235 -0
  104. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/alpha.py +560 -0
  105. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/asr.py +1237 -0
  106. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/color.py +540 -0
  107. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/decision.py +2452 -0
  108. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/drawtext.py +290 -0
  109. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emit.py +1309 -0
  110. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/emoji.py +518 -0
  111. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/fonts.py +875 -0
  112. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing.py +263 -0
  113. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/pacing_edit.py +432 -0
  114. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/probe.py +1613 -0
  115. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/runner.py +3994 -0
  116. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/text.py +73 -0
  117. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/timeline.py +721 -0
  118. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_common/wrap.py +981 -0
  119. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_contract.py +2454 -0
  120. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_platforms.py +258 -0
  121. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.html +754 -0
  122. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_review.py +258 -0
  123. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/_smartcut.py +450 -0
  124. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/audio.py +867 -0
  125. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/background.py +136 -0
  126. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/batch.py +1409 -0
  127. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/broll.py +282 -0
  128. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/caption.py +2207 -0
  129. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/check.py +815 -0
  130. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/color.py +695 -0
  131. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/crop.py +91 -0
  132. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cropdetect.py +214 -0
  133. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/cut.py +2076 -0
  134. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/deinterlace.py +90 -0
  135. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/denoise.py +94 -0
  136. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/export.py +1033 -0
  137. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/fit.py +729 -0
  138. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/freeze.py +197 -0
  139. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/graphics.py +920 -0
  140. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/grid.py +235 -0
  141. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/insert.py +142 -0
  142. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/join.py +1083 -0
  143. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/look.py +475 -0
  144. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loop.py +395 -0
  145. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/loudness.py +397 -0
  146. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/metadata.py +416 -0
  147. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/multicam.py +414 -0
  148. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/overlay.py +766 -0
  149. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/pad.py +121 -0
  150. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/probe.py +145 -0
  151. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/proxy.py +93 -0
  152. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/redact.py +162 -0
  153. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/render.py +2424 -0
  154. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/report.py +354 -0
  155. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/reverse.py +114 -0
  156. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/scenes.py +439 -0
  157. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sequence.py +285 -0
  158. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/silence.py +945 -0
  159. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/speedramp.py +193 -0
  160. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sphere.py +137 -0
  161. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/stabilize.py +141 -0
  162. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/straighten.py +120 -0
  163. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/sync.py +500 -0
  164. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/verify.py +411 -0
  165. package/workspace/.agents/skills/cleoedits/scripts/ffmpeg/waveform.py +502 -0
  166. package/workspace/.agents/skills/cleoedits/scripts/kdenlive_builder.py +284 -0
  167. package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-claude-motion +21 -0
  168. package/workspace/.agents/skills/cleoedits/scripts/motion/LICENSE-motion-design +21 -0
  169. package/workspace/.agents/skills/cleoedits/scripts/motion/_media.py +43 -0
  170. package/workspace/.agents/skills/cleoedits/scripts/motion/pacing_check.py +90 -0
  171. package/workspace/.agents/skills/cleoedits/scripts/motion/storyboard.py +77 -0
  172. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/LICENSE +26 -0
  173. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/fx.py +2717 -0
  174. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/logos.py +194 -0
  175. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/sfx.py +105 -0
  176. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/trim.py +99 -0
  177. package/workspace/.agents/skills/cleoedits/scripts/reel_effects/words.py +60 -0
  178. package/workspace/.claude/commands/blender-3d.md +12 -0
  179. package/workspace/.claude/commands/business-short-form-reels.md +12 -0
  180. package/workspace/.claude/commands/color-grade.md +12 -0
  181. package/workspace/.claude/commands/cutout-grid-reel.md +12 -0
  182. package/workspace/.claude/commands/depth-ui-reel.md +12 -0
  183. package/workspace/.claude/commands/explainer-panel-reel.md +12 -0
  184. package/workspace/.claude/commands/freeze-frame.md +12 -0
  185. package/workspace/.claude/commands/glass-graph.md +12 -0
  186. package/workspace/.claude/commands/over-the-shoulder.md +12 -0
  187. package/workspace/.claude/commands/personal-short-form-reels.md +12 -0
  188. package/workspace/.claude/commands/ranking-format.md +12 -0
  189. package/workspace/.claude/commands/relight.md +12 -0
  190. package/workspace/.claude/commands/reverse-engineer.md +12 -0
  191. package/workspace/.claude/commands/text-behind.md +12 -0
  192. package/workspace/.claude/commands/tier-list.md +12 -0
  193. package/workspace/.claude-plugin/plugin.json +8 -0
  194. package/workspace/.npmignore +15 -0
  195. package/workspace/AGENTS.md +30 -0
  196. package/workspace/README.md +63 -0
  197. package/workspace/assets/fonts/TikTokSans-OFL.txt +93 -0
  198. package/workspace/assets/fonts/TikTokSans-Variable.ttf +0 -0
  199. package/workspace/assets/luts/clean_warm.cube +4917 -0
  200. package/workspace/assets/luts/golden_hour.cube +4917 -0
  201. package/workspace/assets/luts/moody_dark.cube +4917 -0
  202. package/workspace/assets/luts/teal_orange.cube +4917 -0
  203. package/workspace/assets/sfx/NOTICE.txt +1 -0
  204. package/workspace/assets/sfx/click.wav +0 -0
  205. package/workspace/assets/sfx/pop.wav +0 -0
  206. package/workspace/assets/sfx/riser.wav +0 -0
  207. package/workspace/assets/sfx/whoosh.wav +0 -0
  208. package/workspace/generators/hyperframes/index.html +39 -0
  209. package/workspace/generators/hyperframes/package.json +15 -0
  210. package/workspace/generators/hyperframes/pnpm-lock.yaml +1181 -0
  211. package/workspace/generators/hyperframes/pnpm-workspace.yaml +10 -0
  212. package/workspace/generators/remotion/eslint.config.mjs +3 -0
  213. package/workspace/generators/remotion/package.json +36 -0
  214. package/workspace/generators/remotion/pnpm-lock.yaml +4179 -0
  215. package/workspace/generators/remotion/pnpm-workspace.yaml +10 -0
  216. package/workspace/generators/remotion/remotion.config.ts +13 -0
  217. package/workspace/generators/remotion/src/Root.tsx +52 -0
  218. package/workspace/generators/remotion/src/index.css +1 -0
  219. package/workspace/generators/remotion/src/index.ts +4 -0
  220. package/workspace/generators/remotion/tsconfig.json +15 -0
  221. package/workspace/pipeline/scripts/_codec.py +28 -0
  222. package/workspace/pipeline/scripts/ai_media_api.py +109 -0
  223. package/workspace/pipeline/scripts/blender_render.py +166 -0
  224. package/workspace/pipeline/scripts/composite.py +49 -0
  225. package/workspace/pipeline/scripts/melt.sh +68 -0
  226. package/workspace/pipeline/scripts/normalize_audio.py +39 -0
  227. package/workspace/pipeline/scripts/person_matte.py +216 -0
  228. package/workspace/pipeline/scripts/record_demo.py +69 -0
  229. package/workspace/pipeline/scripts/whisper_cut.py +98 -0
  230. package/workspace-manifest.json +908 -0
@@ -0,0 +1,416 @@
1
+ #!/usr/bin/env python3
2
+ """Write container chapters and title/artist/comment tags without touching the streams.
3
+
4
+ Chapter markers are what YouTube, VLC, Apple Podcasts and MKV players show as a
5
+ seekable list; graphics.py --template chapter burns a *card* into the picture, this
6
+ writes the *metadata*. Every stream is copied bit for bit (-c copy): the only thing
7
+ that changes is the container's metadata, so this is instant and lossless.
8
+
9
+ Chapters come from a text file, one per line, `TIME TITLE` with the same time syntax
10
+ as cut.py (seconds, mm:ss, hh:mm:ss.ms). Each chapter ends where the next starts; the
11
+ last one ends at the file's duration. Containers with no chapter support (.wav, .gif,
12
+ .mp3, .flac) are refused for --chapters rather than silently dropping them; tags alone
13
+ are written wherever the container can hold them.
14
+
15
+ Examples:
16
+ python3 metadata.py episode.mp4 --chapters chapters.txt
17
+ python3 metadata.py episode.mp4 --title "Episode 12" --artist "Studio" --comment "final cut"
18
+ python3 metadata.py master.mkv --chapters chapters.txt --title "Master" -o master_tagged.mkv
19
+ python3 metadata.py episode.mp4 --clear-chapters
20
+
21
+ chapters.txt:
22
+ 0:00 Intro
23
+ 2:15 Setup
24
+ 1:03:00 Outro
25
+ """
26
+ import argparse
27
+ import re
28
+ import json
29
+ import os
30
+ import sys
31
+ import tempfile
32
+ from pathlib import Path
33
+ from typing import Any, Dict, List, Optional
34
+
35
+ from _common import (guard_sidecar, add_common, apply_common, default_output, description_block, detect_scenes, detect_silences,
36
+ die, emit, ffmpeg_base, fmt_chapter_time, info, propose_chapters, time_arg, probe, run,
37
+ STATE, read_text_or_die)
38
+ from _common.emit import input_length, refuse_still
39
+ from _common.emit import record_fallback, refuse
40
+ from _common.probe import AUDIO_MEDIA_EXT
41
+ from _common.runner import (absent_word, MATROSKA_EXT, MP4_FAMILY, carried_stream_maps, fail_if_classified, refuse_output_is_input, require_tool,
42
+ subtitle_codec_for, subtitle_container_holds)
43
+
44
+ CHAPTER_CONTAINERS = {".mp4", ".m4v", ".m4a", ".mov", ".mkv", ".mka", ".webm"}
45
+ TAG_KEYS = ("title", "artist", "album", "comment", "date", "genre")
46
+
47
+
48
+ def non_av_streams(path: str) -> List[Dict[str, Any]]:
49
+ """The subtitle, data and attachment streams of `path` ({index, type, codec, tag}), without an
50
+ MP4/MOV chapter track when the file has chapters: the muxer writes that one again from the
51
+ chapters and the copy leaves it out (carried_stream_maps, A173). A list that cannot be read
52
+ stops the run: an empty one would let through what the check below is there to refuse."""
53
+ proc = run([require_tool("ffprobe"), "-v", "error", "-show_entries",
54
+ "stream=index,codec_type,codec_name,codec_tag_string:chapter=id", "-of", "json", path], quiet=True)
55
+ try:
56
+ doc = json.loads(proc.stdout or "")
57
+ except ValueError:
58
+ die(f"ffprobe's stream list for {path} did not parse", kind="ffmpeg")
59
+ out = []
60
+ for s in doc.get("streams") or []:
61
+ tag = str(s.get("codec_tag_string") or "").lower()
62
+ if s.get("codec_type") not in ("subtitle", "data", "attachment") or (doc.get("chapters") and s.get("codec_type") == "data" and tag == "text"):
63
+ continue
64
+ out.append({"index": s.get("index"), "type": s.get("codec_type"), "codec": s.get("codec_name") or tag or "unknown", "tag": tag})
65
+ return out
66
+
67
+
68
+ def refuse_uncopyable_streams(streams: List[Dict[str, Any]], src: str, output: str) -> None:
69
+ """Refuse, before ffmpeg runs, a stream the output's container does not take as a copy (#539).
70
+ Every stream is copied here (`-map 0 -c copy`), so a text track cannot be converted as
71
+ export.py converts it, and the muxer refused the whole file: `kind: ffmpeg` after a dry run
72
+ that said completed. Only what the three container families are known to refuse is judged
73
+ (MPEG-4, Matroska, WebM; measured on FFmpeg 6.1.1): a subtitle track in another format than
74
+ the container's own, a data stream into Matroska or WebM, an attachment outside Matroska. Any
75
+ other container is left to its muxer."""
76
+ ext = Path(output).suffix.lower().lstrip(".")
77
+ matroska = "." + ext in MATROSKA_EXT
78
+ mpeg4 = ext in MP4_FAMILY or ext == "m4a" # .m4a is the same muxer family: no SubRip there either
79
+ if not (mpeg4 or matroska or ext == "webm"):
80
+ return
81
+ family = "mkv" if matroska else "mp4" if ext == "m4a" else ext # .mka and .mks hold what .mkv holds
82
+ refused = []
83
+ for s in streams:
84
+ if s["type"] == "subtitle":
85
+ ok = subtitle_container_holds(s["codec"], family) and subtitle_codec_for(s["codec"], family) == "copy"
86
+ elif s["type"] == "data":
87
+ ok = mpeg4
88
+ else:
89
+ ok = matroska
90
+ if not ok:
91
+ refused.append(f"stream {s['index']} ({s['type']}, {s['codec']})")
92
+ if not refused:
93
+ return
94
+ src_ext = Path(src).suffix.lower() or "the source's own"
95
+ die(f"{output}: a .{ext} file does not hold {', '.join(refused)} of {src} as a copy, and metadata.py copies every "
96
+ "stream as it is; nothing was written", kind="input",
97
+ hint=f"write a {src_ext} file (the default output keeps the source's container), or change the container first "
98
+ "with export.py --preset copy, which converts a text subtitle track and says which streams it left out")
99
+
100
+
101
+ def parse_chapters(path: str, duration: float) -> List[Dict[str, Any]]:
102
+ """`TIME TITLE` per line -> [{"start", "end", "title"}], validated: ascending starts, every
103
+ start inside the file, the last chapter running to the file's end."""
104
+ text = read_text_or_die(path, "--chapters")
105
+ entries: List[Dict[str, Any]] = []
106
+ for n, raw in enumerate(text.split("\n"), start=1): # not splitlines(): a title may hold U+2028
107
+ line = raw.strip()
108
+ if not line or line.startswith("#"):
109
+ continue
110
+ parts = line.split(None, 1)
111
+ vtt_header = not entries and line.upper().startswith("WEBVTT")
112
+ if vtt_header or (len(parts) > 1 and parts[1].startswith("-->")):
113
+ # a WebVTT header or an SRT/WebVTT timing line: read as chapters, its cue numbers and
114
+ # times became chapter starts and the run failed on their order, never naming the file (#404)
115
+ what = "a WebVTT header" if vtt_header else "a subtitle timing line"
116
+ die(f"{path}:{n}: `{line[:60]}` is {what}, so this is an SRT/WebVTT subtitle file, "
117
+ "not a chapter list (one chapter per line: `0:00 Intro`)", kind="input")
118
+ # chapter files carry no fps, so hh:mm:ss:ff needs its @fps suffix; time_arg() says so
119
+ start = time_arg(parts[0], f"{path}:{n}")
120
+ # `0:00 - Intro` (the form YouTube descriptions use): the separator is not part of the title
121
+ title = re.sub(r"^[-\u2013\u2014|:]\s+", "", parts[1].strip()) if len(parts) > 1 else ""
122
+ title = title or f"Chapter {len(entries) + 1}"
123
+ if "\x00" in title:
124
+ # FFmpeg ends a metadata value at NUL: "A\x00B" was written as "A", verified (the
125
+ # sibling of A260 in render.py's inline chapters)
126
+ die(f"{path}:{n}: the chapter title holds a NUL character, which a chapter title cannot carry; remove it")
127
+ if entries and start <= entries[-1]["start"]:
128
+ die(f"{path}:{n}: chapter at {start:g}s does not come after the previous one at {entries[-1]['start']:g}s")
129
+ if duration and start >= duration:
130
+ die(f"{path}:{n}: chapter at {start:g}s starts at or after the end of the file ({duration:.3f}s)")
131
+ entries.append({"start": start, "title": title})
132
+ if not entries:
133
+ die(f"{path}: no chapters found (one per line: `0:00 Intro`)")
134
+ for i, e in enumerate(entries):
135
+ e["end"] = entries[i + 1]["start"] if i + 1 < len(entries) else duration
136
+ return entries
137
+
138
+
139
+ def _ffmeta_escape(value: str) -> str:
140
+ # ffmetadata: backslash escapes =, ;, #, \ and newline
141
+ out = []
142
+ for ch in value:
143
+ if ch in "=;#\\":
144
+ out.append("\\" + ch)
145
+ elif ch == "\n":
146
+ out.append("\\\n")
147
+ else:
148
+ out.append(ch)
149
+ return "".join(out)
150
+
151
+
152
+ def write_ffmetadata(chapters: List[Dict[str, Any]], path: str) -> None:
153
+ lines = [";FFMETADATA1"]
154
+ for c in chapters:
155
+ lines += ["[CHAPTER]", "TIMEBASE=1/1000", f"START={int(round(c['start'] * 1000))}",
156
+ f"END={int(round(c['end'] * 1000))}", f"title={_ffmeta_escape(c['title'])}"]
157
+ Path(path).write_text("\n".join(lines) + "\n", encoding="utf-8")
158
+
159
+
160
+ def propose(args, meta: Dict[str, Any], duration: float,
161
+ notes: List[str]) -> "tuple":
162
+ """--auto-chapters: measure the structure, then hand it to the pure proposer.
163
+
164
+ The detectors are the ones silence.py and scenes.py run (they live in _common/probe.py since
165
+ 1.16 so that no tool has to import another tool); the decision is propose_chapters(), which
166
+ is pure and never looks at content.
167
+ """
168
+ source = args.detect_from
169
+ if not meta.get("audio") and source in ("silence", "both"):
170
+ if source == "silence":
171
+ die("--from silence needs an input with an audio stream; use --from scenes", kind="input")
172
+ source = "scenes"
173
+ notes.append("no audio stream: the markers come from scene changes alone (--from scenes)")
174
+ if not meta.get("video") and source in ("scenes", "both"):
175
+ if source == "scenes":
176
+ die("--from scenes needs an input with a video stream; use --from silence", kind="input")
177
+ source = "silence"
178
+ notes.append("no video stream: the markers come from the pauses alone (--from silence)")
179
+ silences = detect_silences(args.input, args.silence_threshold, args.silence_min) \
180
+ if source in ("silence", "both") else []
181
+ cuts = detect_scenes(args.input, args.scene_threshold, 1.0, duration) \
182
+ if source in ("scenes", "both") else []
183
+ if source == "both":
184
+ notes.append("measured in 2 passes (silencedetect and scdet each decode the file once); "
185
+ "--from silence is the cheap path")
186
+ proposed = propose_chapters(duration, silences, cuts, min_chapter=args.min_chapter,
187
+ max_chapters=args.max_chapters, source=source)
188
+ if len(proposed) == 1:
189
+ # every suggestion has to be a value the caller is not already using, or the hint reads
190
+ # "try --min-chapter 1" to someone who passed --min-chapter 1
191
+ tries = []
192
+ shorter_silence = round(args.silence_min / 2.0, 2)
193
+ if shorter_silence >= 0.1 and shorter_silence < args.silence_min:
194
+ tries.append(f"--silence-min {shorter_silence:g}")
195
+ shorter_chapter = max(1.0, round(args.min_chapter / 2.0, 2))
196
+ if shorter_chapter < args.min_chapter:
197
+ tries.append(f"--min-chapter {shorter_chapter:g}")
198
+ if args.detect_from != "both" and meta.get("audio") and meta.get("video"):
199
+ tries.append("--from both")
200
+ notes.append(f"no pause longer than {args.silence_min:g}s and no scene change far enough apart "
201
+ "to start a chapter: the file gets one marker at 0:00"
202
+ + (". Try " + " or ".join(tries) if tries else
203
+ ", and the thresholds are already as low as this tool will suggest"))
204
+ total = len([1 for _s in silences]) + len([c for c in cuts if c > 0])
205
+ auto = {
206
+ "source": {"silence": "silence", "scenes": "scenes", "both": "silence+scenes"}[source],
207
+ "min_chapter": float(args.min_chapter),
208
+ "max_chapters": int(args.max_chapters),
209
+ "proposed": total,
210
+ "kept": len(proposed),
211
+ "titles": "placeholder",
212
+ "chapters": proposed,
213
+ "description_block": description_block(proposed),
214
+ }
215
+ entries = [{"start": c["at"], "title": c["title"]} for c in proposed]
216
+ for i, e in enumerate(entries):
217
+ e["end"] = entries[i + 1]["start"] if i + 1 < len(entries) else duration
218
+ info(f"proposed {len(entries)} chapters from {auto['source']} "
219
+ f"(titles are placeholders: Chapter 1..{len(entries)})")
220
+ return entries, auto
221
+
222
+
223
+ def write_proposal(args, chapters: List[Dict[str, Any]]) -> Dict[str, Any]:
224
+ """--chapters-out / --description-out, the two side files a caller edits and feeds back."""
225
+ files: Dict[str, Any] = {"chapters": None, "description": None}
226
+ if args.chapters_out:
227
+ body = "\n".join(f"{fmt_chapter_time(c['at'])} {c['title']}" for c in chapters) + "\n"
228
+ if STATE.dry_run:
229
+ info(f"[dry-run] would write {args.chapters_out} ({len(chapters)} chapters)")
230
+ else:
231
+ Path(args.chapters_out).write_text(body, encoding="utf-8")
232
+ info(f"wrote {args.chapters_out} ({len(chapters)} chapters)")
233
+ files["chapters"] = args.chapters_out
234
+ if args.description_out:
235
+ body = description_block(chapters) + "\n"
236
+ if STATE.dry_run:
237
+ info(f"[dry-run] would write {args.description_out}")
238
+ else:
239
+ Path(args.description_out).write_text(body, encoding="utf-8")
240
+ info(f"wrote {args.description_out}")
241
+ files["description"] = args.description_out
242
+ return files
243
+
244
+
245
+ def main() -> int:
246
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
247
+ ap.add_argument("input")
248
+ ap.add_argument("-o", "--output", help="output file (default: <name>_meta.<ext>)")
249
+ ap.add_argument("--chapters", help="text file, one chapter per line: `TIME TITLE` (cut.py time syntax)")
250
+ ap.add_argument("--chapter", action="append", metavar="TIME=TITLE", help="one chapter, repeatable (--chapter 0:00=Intro --chapter 1:30=Main), instead of a --chapters file")
251
+ ap.add_argument("--clear-chapters", action="store_true", help="remove every chapter marker the input carries")
252
+ auto = ap.add_argument_group("proposed chapters (1.16)",
253
+ "Chapter timestamps measured from the file's own structure instead of read from a "
254
+ "file. The markers are proposed, the titles are not: every one is `Chapter N` and "
255
+ "renaming them is the caller's job -- knowing what is said in a chapter is not "
256
+ "something this skill can measure. Two detectors mean two full decodes of the "
257
+ "input; --from silence is the cheap path.")
258
+ auto.add_argument("--auto-chapters", action="store_true",
259
+ help="propose the markers from measured pauses and scene changes instead of reading --chapters FILE")
260
+ auto.add_argument("--min-chapter", type=float, default=60.0,
261
+ help="shortest chapter in seconds (default 60, a long-form default: a 12-minute episode gets at most 12)")
262
+ auto.add_argument("--max-chapters", type=int, default=0,
263
+ help="cap the number of markers (default 0 = no cap); the weakest evidence is dropped first")
264
+ auto.add_argument("--from", dest="detect_from", choices=["silence", "scenes", "both"], default="both",
265
+ help="which detector(s) propose the markers (default both)")
266
+ auto.add_argument("--silence-threshold", type=float, default=-35.0,
267
+ help="silence level in dBFS for --auto-chapters (default -35)")
268
+ auto.add_argument("--min-silence", "--silence-min", dest="silence_min", type=float, default=1.5,
269
+ help="a pause must last this long to propose a chapter (default 1.5 -- deliberately longer than silence.py's 0.6: a chapter break is a long pause)")
270
+ auto.add_argument("--scene-threshold", type=float, default=8.0,
271
+ help="minimum scdet score for a scene cut with --auto-chapters (default 8, as scenes.py)")
272
+ auto.add_argument("--chapters-out", help="write the proposal as a `TIME TITLE` file in this tool's own --chapters format, so the titles can be edited and fed back")
273
+ auto.add_argument("--description-out", help="write the YouTube description block (`00:00 Chapter 1` per line)")
274
+ for key in TAG_KEYS:
275
+ ap.add_argument(f"--{key}", help=f"set the container's {key} tag (empty string clears it)")
276
+ add_common(ap)
277
+ args = ap.parse_args()
278
+ apply_common(args)
279
+ if args.auto_chapters: # the only mode that writes them
280
+ # against the video this run writes, the default name too (A6, #465: --chapters-out at
281
+ # input_meta.mp4 wrote the chapter text over the video it had just written)
282
+ video_out = args.output or default_output(args.input, "meta", Path(args.input).suffix.lstrip(".") or "mp4")
283
+ guard_sidecar(args.chapters_out, args.input, siblings=(args.description_out, video_out))
284
+ guard_sidecar(args.description_out, args.input, siblings=(video_out,))
285
+
286
+ if args.chapters and args.clear_chapters:
287
+ die("--chapters and --clear-chapters exclude each other")
288
+ if args.auto_chapters and (args.chapters or args.clear_chapters):
289
+ die("--auto-chapters proposes the markers; it excludes --chapters FILE and --clear-chapters")
290
+ if args.min_chapter <= 0:
291
+ die(f"--min-chapter must be > 0, got {args.min_chapter:g}")
292
+ if args.max_chapters < 0:
293
+ die(f"--max-chapters must be >= 0 (0 = no cap), got {args.max_chapters}")
294
+ if args.silence_min < 0:
295
+ # A185: a negative length reached silencedetect, which refused it (kind ffmpeg)
296
+ die(f"--silence-min must be 0 or more seconds, got {args.silence_min:g}")
297
+ if args.chapter and not args.chapters:
298
+ # the same list --chapters reads, written beside nothing: a temporary file removed at exit
299
+ import atexit
300
+ with tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False, encoding="utf-8") as listed:
301
+ listed.write("".join(c.replace("=", " ", 1) + "\n" for c in args.chapter))
302
+ args.chapters = listed.name
303
+ atexit.register(os.unlink, listed.name)
304
+ tags = {k: getattr(args, k) for k in TAG_KEYS if getattr(args, k) is not None}
305
+ if not args.chapters and not args.clear_chapters and not args.auto_chapters and not tags:
306
+ die("nothing to write: give --chapters FILE, --auto-chapters, --clear-chapters and/or --title/--artist/...")
307
+ if args.chapters and not os.path.exists(args.chapters):
308
+ die(f"chapters file {absent_word(args.chapters)}: {args.chapters}")
309
+
310
+ meta = probe(args.input)
311
+ # streams are copied, so the source's own container always holds them (a .webm stays .webm)
312
+ output = args.output or default_output(args.input, "meta", Path(args.input).suffix.lstrip(".") or "mp4")
313
+ if os.path.abspath(output) == os.path.abspath(args.input):
314
+ die("output must differ from the input (metadata.py never rewrites a file in place)")
315
+ if args.chapters:
316
+ # the chapter list is read here and handed to ffmpeg as a metadata file of its own (#522's sweep)
317
+ refuse_output_is_input(output, args.chapters, why="the chapter file would be replaced by the output")
318
+ out_ext = Path(output).suffix.lower()
319
+ if (args.chapters or args.clear_chapters or args.auto_chapters) and out_ext not in CHAPTER_CONTAINERS:
320
+ die(f"{out_ext or 'this'} container cannot hold chapter markers; write to one of "
321
+ f"{', '.join(sorted(CHAPTER_CONTAINERS))} (the streams are copied, so choose the matching family: .mp4/.mov/.m4a for MPEG-4, .mkv/.mka/.webm for Matroska)")
322
+
323
+ # the last chapter ends at the file's end and --auto-chapters spaces them over its length (#491);
324
+ # a still's 0 s ended a chapter before it started, inside ffmpeg (kind ffmpeg, #531)
325
+ if args.chapters or args.auto_chapters:
326
+ refuse_still(meta, args.input, "chapters are times in a clip, and a still has none")
327
+ duration = input_length(meta) if (args.chapters or args.auto_chapters) else (meta.get("duration") or 0.0)
328
+ chapters: Optional[List[Dict[str, Any]]] = parse_chapters(args.chapters, duration) if args.chapters else None
329
+ auto: Optional[Dict[str, Any]] = None
330
+ notes: List[str] = []
331
+ if args.auto_chapters:
332
+ chapters, auto = propose(args, meta, duration, notes)
333
+
334
+ # a planned input not yet written (a dry run of a later stage) has a placeholder picture, not a
335
+ # measured one: its own extension says what it will hold (#554 review)
336
+ pending_sound = bool(meta.get("dry_run")) and os.path.splitext(args.input)[1].lower() in AUDIO_MEDIA_EXT
337
+ if out_ext in AUDIO_MEDIA_EXT and meta.get("video") and not pending_sound:
338
+ # the picture is copied with everything else: .m4a took it (H.264 in a file named for
339
+ # sound) and .wav failed in its muxer; the reason the tools that encode a picture give (#539)
340
+ refuse("input", "output_extension_audio_only",
341
+ f"output {output!r}: {out_ext} holds sound only, and metadata.py copies every stream of "
342
+ f"{args.input}, its picture ({meta['video'].get('codec')}) included",
343
+ hint="name a video file of the source's container; for the sound alone, cut.py or audio.py with an "
344
+ "audio extension extracts it",
345
+ output=output, extension=out_ext, encoders=[])
346
+ streams = [] if meta.get("dry_run") else non_av_streams(args.input)
347
+ refuse_uncopyable_streams(streams, args.input, output)
348
+
349
+ cmd = ffmpeg_base() + ["-i", args.input]
350
+ tmpdir = None
351
+ if chapters:
352
+ tmpdir = tempfile.TemporaryDirectory(prefix="ffskill_meta_")
353
+ ffmeta = os.path.join(tmpdir.name, "chapters.ffmeta")
354
+ write_ffmetadata(chapters, ffmeta)
355
+ cmd += ["-i", ffmeta, "-map", "0", "-map_metadata", "0", "-map_chapters", "1"]
356
+ elif args.clear_chapters:
357
+ cmd += ["-map", "0", "-map_metadata", "0", "-map_chapters", "-1"]
358
+ else:
359
+ cmd += ["-map", "0", "-map_metadata", "0", "-map_chapters", "0"]
360
+ # not the source's MP4/MOV chapter track: the muxer writes one from the chapters it is given,
361
+ # and the copy was a stray data track holding the old titles (A173)
362
+ cmd += carried_stream_maps(args.input, output, attachments=False)
363
+ tail: List[str] = []
364
+ for key, value in tags.items():
365
+ tail += ["-metadata", f"{key}={value}"]
366
+ tail += ["-c", "copy"]
367
+ if out_ext in (".mp4", ".mov", ".m4v", ".m4a"):
368
+ # A stream copy into the MPEG-4 family writes the index (moov) after the media unless told
369
+ # otherwise, so without +faststart a faststart input -- render's export -- came out with
370
+ # its index at the end (#415; every other MP4 write here is faststart since #279)
371
+ tail += ["-movflags", "+faststart"]
372
+ tail.append(output)
373
+ timecode_tracks = [s for s in streams if s["type"] == "data" and s["tag"] == "tmcd"]
374
+ if timecode_tracks and out_ext in (".mp4", ".m4v"):
375
+ # FFmpeg 6.1.1's MP4 muxer refuses a copied timecode (tmcd) track ("Could not find tag for
376
+ # codec none"; .mov takes it), so every MP4 with a start timecode failed here, in its own
377
+ # container. The copy is tried as it is, for an FFmpeg that takes it; when it is refused
378
+ # the track alone is left out and the muxer writes one again from the picture's timecode
379
+ # tag, which the copy carries (the label is compared by emit's source_carry)
380
+ proc = run(cmd + tail, check=False)
381
+ if proc.returncode != 0:
382
+ fail_if_classified(proc)
383
+ error = " | ".join([ln.strip() for ln in (proc.stderr or "").splitlines() if ln.strip()][-3:])[-500:]
384
+ record_fallback(f"the timecode track could not be copied into {os.path.basename(output)} "
385
+ f"({error or 'ffmpeg exit ' + str(proc.returncode)}); copying again without it, "
386
+ "the muxer writes it from the picture's timecode tag",
387
+ "non_av_streams_dropped", output=output, returncode=proc.returncode, error=error, dropped=["data"])
388
+ for s in timecode_tracks:
389
+ cmd += ["-map", f"-0:{s['index']}"]
390
+ # .m4v is written by the ipod muxer, which writes no timecode track unless asked: the
391
+ # retry completed without the timecode there (#554 review)
392
+ run(cmd + tail[:-1] + (["-write_tmcd", "1"] if out_ext == ".m4v" else []) + tail[-1:])
393
+ else:
394
+ run(cmd + tail)
395
+ if tmpdir:
396
+ tmpdir.cleanup()
397
+
398
+ result = probe(output, role="output")
399
+ written = result.get("chapters") or []
400
+ if chapters is not None and not STATE.dry_run and len(written) != len(chapters):
401
+ die(f"wrote {len(written)} chapters but {len(chapters)} were asked for", kind="output")
402
+ if args.clear_chapters and not STATE.dry_run and written:
403
+ die(f"{len(written)} chapters survived --clear-chapters", kind="output")
404
+ info(f"wrote {output} ({len(written)} chapters, tags: {', '.join(sorted(tags)) or 'unchanged'}, streams copied)")
405
+ extra: Dict[str, Any] = {}
406
+ if auto is not None:
407
+ auto["files"] = write_proposal(args, auto["chapters"])
408
+ extra["auto_chapters"] = auto
409
+ if notes:
410
+ extra["notes"] = notes
411
+ emit(output, chapters=written, tags=result.get("tags") or {}, streams_copied=True, **extra)
412
+ return 0
413
+
414
+
415
+ if __name__ == "__main__":
416
+ sys.exit(main())