Reverts 1d3d20c (NVDEC decode + quarter-size blur): it changed the
delivered pixels (SSIM 0.998-0.9997, not identical), and clips must not
change. Replaces it with two fixes that leave every clip byte-identical.
- Parakeet's onnxruntime pool threads no longer spin
(transcribe_backends.parakeet_session_options). While the GPU did the
work they burned ~160 CPU-s per 9 min of audio, the biggest CPU cost of
a job. The VAD keeps load_vad's defaults: any options there make
onnx_asr drop its default providers and a word changes.
- analyze_scenes_strategy and split_layout read their sampled frames in
one forward pass (frame_sampler.read_at) instead of a seek per sample,
which re-decoded the GOP every time: 89 -> 6 CPU-s for one clip's
samples, same frames.
Bench on balrog, 3 Carlos Gracia videos (2.5/9/17 min, 15 clips), Gemini
decisions recorded once and replayed: every clip identical to the old
code (decoded-frame MD5s + audio). Serial stage profile of the 9 min
video: 629 -> 273 CPU-s per job; Python side 332 -> 57 CPU-s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At peak (8 jobs x 3 clip workers) balrog sat at load ~100 on 20 threads
while the RTX 4000's decoder stayed at 0%: NVENC only took the encode, and
decoding plus the filter graphs ran on the CPU, starving the Coolify builds
and every other service on the box.
- ffmpeg_utils.video_decode_args(): -hwaccel cuda before the video input
whenever the encode is on nvenc (FFMPEG_HWDECODE=0 turns it off). Used in
the cut, the reframe v2 segments, watermark, hook and caption passes.
- ffmpeg_utils.blurred_backdrop(): the GENERAL and INSET blurred fill blurs
at a quarter of the output size and scales up, instead of a full-size
gblur on 1080x1920.
Measured in the prod container on a real 1080p source, 10 s GENERAL
segment: ~16-18 s of CPU before, ~5-7 s after, SSIM 0.994 against the old
output. All four hwaccel passes checked end to end on the prod GPU.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cut ran with its return code ignored and stderr captured into a pipe
nobody read, so a failed encode left an empty temp file that flowed on to
render_clip. The job's only visible error was "moov atom not found",
reported three layers downstream by ffmpeg, TransNetV2 and PySceneDetect in
turn, each naming the temp clip rather than the encode that never wrote it.
In prod on 9-sep-2026 that lost all three clips of a job and the cause was
unrecoverable, because the one process that knew it had been discarded.
cut_clip() now checks the return code AND the file size (ffmpeg has been
seen exiting 0 having written nothing), retries twice on the same encoder
after 3s and 9s, and otherwise raises with ffmpeg's own stderr so the job
error text names the real failure.
The retry deliberately stays on the GPU instead of falling back to libx264:
the failure is transient — the same command on the same source cut fine by
hand minutes later — and the nvenc probe is a 256x256 lavfi frame cached for
the life of the process, so it keeps saying yes while a real 1080p session
cannot allocate on a GPU other jobs are filling.
Claude-Session: https://claude.ai/code/session_01GdkAaRGLyARP5aSZaXXF19
Art. 50(2) asks a provider whose system generates synthetic audio or video to
mark the output in a machine-readable way, and the terms already promised we
"label and mark" dubbed clips while nothing did either.
mark_ai_generated stamps the disclosure by stream copy, so it is a remux and
never a re-encode. The tag is `comment` because mp4 keeps only the standard
tags and ffmpeg drops a custom key without warning, which a test pins. It is
best effort by design: a missing tag must not lose someone the video they just
paid minutes for.
Deliberately narrow, on dubbing and AI actors, not on an ordinary clip whose
pixels and audio are the user's own footage. Marking everything would make the
tag mean nothing. TranslateModal says the file is tagged and that the person
publishing it owes their audience the disclosure, which is the art. 50(4) duty
and falls on them, not on us.
Still missing, and a product decision rather than an oversight: the visible
burned-in label.
Claude-Session: https://claude.ai/code/session_01WyFE2wXi8quZR6nLRRLDgE
reframe_v2 built its filtergraph as sendcmd=f='<abs path>' with the path
interpolated raw. On Windows tempfile.mkdtemp() returns C:\Users\..., and
the drive colon terminates the filter option, so ffmpeg exits non-zero and
every TRACK scene silently falls back to the v1 Python frame loop. GENERAL
and SPLIT hide the bug because only the TRACK branch emits a sendcmd.
subtitles._escape_ffmpeg_filter_value already solved exactly this for the
ass/fontsdir filter three modules away, so this moves it to ffmpeg_utils as
escape_filter_value() and uses it in both places. subtitles keeps its
wrapper and its docstring; behaviour there is unchanged (verified equal
output on absolute, relative and space/comma paths).
Measured on a 12s 1280x720 clip with one face, Windows 10 + ffmpeg 9:
before 53.5s "Reframe v2 failed (CalledProcessError ...)" -> v1 loop
after 30.8s v2 native, same framing
Also: `-o <dir>` crashed with PermissionError [WinError 5] because
--skip-analysis passed the directory straight through as the output
filename and it reached os.remove(). --output is documented as "directory
or file", so derive the filename when it names a directory, and guard the
stale-file sweep with isfile() so a directory can never be handed to
os.remove().
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiYkHKB7Tp7X6NdnEutda2
Two defects affecting EVERY clip, both measured on the corpus.
Audio: loudnorm hits the level target (median -14.2 LUFS, 13/14 inside the
band) but its true-peak ceiling is enforced BEFORE the AAC encode, and the
codec then adds inter-sample peaks on top. At TP=-1.5 one clip came out at
+0.2 dBTP, i.e. clipping. TP=-2.0 removes it at no cost to level (12/14 in
band); -3.0 does cost level (8/14). Tried and rejected: an alimiter afterwards
(limits sample peaks, not inter-sample, and measured WORSE at +0.7) and
two-pass loudnorm with linear=true (+0.4, still clipping).
Punch-in: the shipped defaults produced 8.4 punches per minute, one every seven
seconds. Swept both knobs over 20 clips; 18s/0.60 gives a median of 2.8 and a
max of 3.0, chosen for having the tightest spread rather than just the right
median.
Captions must always be the LAST layer. Editing or hooking a clip that already
had them burned in produced `edited_subtitled_<...>`, and the next subtitle pass
stacked a second caption layer on top of the first — visibly doubled and
unreadable in a real user clip found in prod today. /api/edit and /api/hook now
derive from the clean file and put captions back afterwards, so a restyle always
has an un-captioned base to burn onto. The latent bug predates auto-captions but
shipping them by default made it the normal path. The walk-back is now one
helper instead of being open-coded in the subtitle endpoint.
Loudness was uncontrolled. A clip inherited whatever its source was mastered at,
measured across real delivered clips from -13.8 LUFS on a loud upload down to
-28 on a quiet talk, while TikTok/Reels/Shorts all normalise playback to around
-14 — so the quiet ones just sound thin in the feed. loudnorm at the clip cut,
where the audio is already being encoded, so it costs nothing. Verified to pull
both extremes to target: -29.7 -> -13.7 and -10.1 -> -13.5. AUDIO_NORMALIZE=0.
The GENERAL layout wasted the frame. Fitting a 16:9 source to full width left
it 608px tall in a 1920 frame: 32% content, 68% blurred filler. Now scaled by
height to 42%, trimming the overflow. Deliberately conservative — GENERAL is
chosen for groups and landscapes, exactly where cropping the sides cuts someone
out, so 0.55 was tried and rejected for throwing away 42% of the width. 0.42
keeps ~76%. GENERAL_CONTENT_HEIGHT_RATIO=0.32 restores the old behaviour.
The TRACK/GENERAL classifier only counted faces, so a screencast that happened
to contain one face was cropped to it — real prod clips came out with headlines
cut mid-word and unreadable. A cheap Canny pass over the side thirds (the part a
9:16 crop discards), with face boxes blanked first, now routes text-dense scenes
to GENERAL instead. GRAPHIC_DENSITY_THRESHOLD=1.0 disables it.
Los clips arrastraban el handler de stream "ISO Media file produced by
Google Inc." del vídeo original de YouTube: ffmpeg copia la metadata del
input por defecto, así que sobrevivía a todos los reencodes y acababa
publicado en la red social. Rastro innecesario del origen.
Se añade METADATA_SCRUB en ffmpeg_utils y se aplica en cada productor de
fichero final: el concat de reframe_v2 (el camino real de prod), el merge
de process_video_to_vertical, el passthrough horizontal, el watermark, y
los reencodes de subtítulos/hooks/editor.
Detalle que costó verificar: -map_metadata -1 global NO basta — el
handler_name a nivel de stream sobrevive a un -c copy. Hacen falta los
especificadores por stream (-map_metadata:s:v -1 -map_metadata:s:a -1);
son inofensivos cuando falta un stream. Verificado con ffprobe sobre un
clip real del pipeline completo: sin rastro de Google.
No promete boost de alcance (eso lo decide el fingerprint de contenido,
no los tags del fichero); es higiene y quitar el rastro del origen.