Clip assembly
Input: segments.json + source media. Output: render.mp4 + edl.json.
The tool
Do not hand-write ffmpeg for this. bots/youtube/scripts/cutroom.py implements
the whole path and is tested on synthetic media:
bashpython bots/youtube/scripts/cutroom.py probe session.mp4 python bots/youtube/scripts/cutroom.py segments session.mp4 --out segments.json python bots/youtube/scripts/cutroom.py edl session.mp4 segments.json --out edl.json python bots/youtube/scripts/cutroom.py render edl.json out/render.mp4 --preset slow --crf 18 python bots/youtube/scripts/cutroom.py verify out/render.mp4 edl.json # exit 1 on failure
segments drops dead air: a detected pause ends the previous chunk and the next
one resumes when the pause ends. verify fails on duration drift > 1 s, a missing
stream, or a true peak above -1.0 dBTP.
Procedure
- Build the EDL first, as JSON, before touching ffmpeg:
json
{"segments":[{"src":"session.mp4","in":128.4,"out":402.9, "transition_in":"fade","lower_third":"sovthpaw"}], "audio":{"target_lufs":-14,"true_peak":-1.5,"lra":11}} - Pad cuts. Start 0.6 s before the hook line, end 0.8 s after the last word. Trimming to the exact word is the single most common amateur tell.
- Cut accurately — put
-ssbefore-ifor speed, but on long sources cut on the nearest keyframe then trim with-ssafter-i:bashffmpeg -ss "$IN" -to "$OUT" -i src.mp4 -c:v libx264 -preset slow -crf 18 \ -r 60 -pix_fmt yuv420p -c:a aac -b:a 192k part.mp4 - Normalize audio once, at the end — never per part, or levels pump between
segments:
bash
ffmpeg -i concat.mp4 -af loudnorm=I=-14:TP=-1.5:LRA=11 -c:v copy out.mp4 - Concat with the concat demuxer on identical-encoded parts, not the filter.
- Dress — title card 3 s, lower third on name first-appearance only, chapter card at each segment start if the segments are presented as chapters.
- Verify before declaring done:
ffprobeduration ±1 s of EDL total, no black frames over 0.5 s, audio peak ≤ -1.0 dBTP, moov atom present. - Emit
edl.json,render.mp4, and a one-line render report (duration, bitrate, loudness, dropped segments and why).
Rules
- Never re-encode twice. One cut pass, one loudnorm pass.
- If a segment's source is variable-frame-rate (OBS default), force CFR 60 first.
- 1080p60 unless the source is lower; never upscale to fake 4K.


