program-master
Skill1 starsChanged 3 months agoMITView on GitHub
TV program segmentation — detect fade-aware black+silent break separators, preserve frame-accurate fade anchors, label content segments, and generate validated thumbnail-led broadcast segment PDF reports. Use when finding commercial breaks, naming episodes/parts, mapping broadcast master structure, or delivering a visual segment report — not hard cuts inside content.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- site/AGENTS.mdAGENTS.md
- site/CLAUDE.mdCLAUDE.md
- audioSkill
- captions-complianceSkill
- downloadSkill
- forced-narrative-exactSkill
- imageSkill
- inspectSkill
- install-media-toolsSkill
- shotsSkill
- speech-captionsSkill
- subtitlesSkill
- timecodeSkill
- video-transformationSkill
- vision-analysisSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
16 rules. About 0 are common, 7 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
If your tools showed a filesystem path when loading this SKILL.md, strip SKILL.md and use that folder.
- Very specific: line 30
If you already ran another mediaskills script (for example .../audio/scripts/extract.py), this skill is a sibling of that folder: same …
- Very specific: line 53
Prefer absolute paths for --input / --output when cwd is uncertain.
- Distinctive: line 58
Before running any script, treat these two failures differently:
- Very specific: line 61
Only escalate sandbox permissions if the error is explicitly a permission denial (e.g.
- Distinctive: line 74
Run this command for normal delivery work:
- Very specific: line 83
Add --label-overrides /absolute/path/labels.json when editorial names are known.
- Distinctive: line 100
Every run must make these choices explicit in the profile or command:
- Very specific: line 116
Start with profiles/broadcast-default.json.
- Very specific: line 130
Use audio_policy: "single" only when that program mix is the declared structure authority.
- Very specific: line 156
Only overlaps meeting min_overlap become structural gaps.
- Distinctive: line 165
Every content row has one source thumbnail at the start of the row.
- Distinctive: line 173
After generation, visually inspect every PDF page for clipped text, missing images, wrong row order, or illegible layout.
- Distinctive: line 184
Use the report’s timecodes exactly.
- Distinctive: line 203
Run the golden test after changing code, thresholds, dependencies, schema, timecode, or rendering:
- Very specific: line 222
Read *_qc.json; require top-level passed: true and no errors.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Program Master
Build a full-coverage broadcast-master structure report from black+silent separators. The canonical workflow produces a labeled manifest, Markdown, structured JSON, a thumbnail-led PDF, and a machine-readable QC result in one run.
Requires Python 3.11+, uv, ffmpeg, and ffprobe. Tesseract is governed by the selected OCR policy. Python dependencies are exactly pinned in the executable scripts.
Running scripts
This skill's scripts live in scripts/ alongside this file. Before running any script, resolve its absolute path from this skill's own directory — do not assume the shell cwd is the skill folder, the repo root, or the workspace. Stay in the workspace (so media paths resolve) and pass the absolute script path to uv run:
uv run <skill_directory>/scripts/doctor.py --profile <skill_directory>/profiles/broadcast-default.json<skill_directory> is a placeholder. Never pass those angle brackets to the shell — the command will fail. Replace it with a real absolute directory before invoking uv run.
How to get that directory (do this yourself; do not ask the user first; do not skip the skill):
- If your tools showed a filesystem path when loading this
SKILL.md, stripSKILL.mdand use that folder. - If you already ran another mediaskills script (for example
.../audio/scripts/extract.py), this skill is a sibling of that folder: same parent, directory nameprogram-master. - Otherwise search standard install locations and confirm the script exists:
NAME=program-master
for d in \
"$HOME/.agents/skills/$NAME" \
"$HOME/.cursor/skills/$NAME" \
"$HOME/.codex/skills/$NAME" \
"$HOME/.claude/skills/$NAME" \
"$PWD/.agents/skills/$NAME" \
"$PWD/.cursor/skills/$NAME" \
"$PWD/skills/$NAME"
do
if [ -f "$d/SKILL.md" ] && [ -e "$d/scripts/run_report.py" ]; then
SKILL_DIR=$(cd "$d" && pwd)
break
fi
done
[ -n "$SKILL_DIR" ] || { echo "mediaskills: $NAME not found" >&2; exit 1; }
uv run "$SKILL_DIR/scripts/run_report.py" --input "<path-to-media>" --output-dir "<report-dir>" --profile "$SKILL_DIR/profiles/broadcast-default.json"Prefer absolute paths for --input / --output when cwd is uncertain. Run the doctor command above before first use on a new system. Profiles live in this skill's profiles/ directory — pass their absolute paths the same way.
Missing binaries vs permissions
Before running any script, treat these two failures differently:
- If a required binary (
uv,ffmpeg,ffprobe,tesseract) reportsNo such file or directoryorcommand not found: this is a missing or unreachable binary, not a permissions issue. Escalating sandbox permissions will not fix it. Runcommand -v uv,command -v ffmpeg,command -v ffprobe, andcommand -v tesseractto see whether they resolve at all. If not, install or re-link them (install-media-toolsdoctor/install) rather than retrying with wider permissions.tesseractis governed by the selected OCR policy (requiredvsoptional/off). - Only escalate sandbox permissions if the error is explicitly a permission denial (e.g.
Operation not permitted,Permission denied).
Shots vs program-master
| Question | Use program-master | Use shots |
| What are you finding? | Structural gaps between programs/parts (black + silent breaks) | Hard cuts inside content (camera angle changes, edits) |
| Typical source | TV master with black+silent separators | Any edited video |
| Output unit | Content segments with labels (episode, commercial, slate text) | Shot list with timecodes |
| Detection method | ffmpeg blackdetect + silencedetect overlap + fade refinement | ffmpeg select=gt(scene,N) |
Use the canonical workflow
Run this command for normal delivery work:
uv run <skill_directory>/scripts/run_report.py \
--input /absolute/path/master.mov \
--output-dir /absolute/path/report_bundle \
--profile <skill_directory>/profiles/broadcast-default.jsonAdd --label-overrides /absolute/path/labels.json when editorial names are known. Do not assemble a final delivery by calling the detector and compiler scripts independently; those scripts are diagnostic components of run_report.py.
The one-command workflow must finish with passed: true. It writes stable names under the requested output directory:
*_labeled_segments.json— authoritative structural manifest and evidence*_program_master.md— complete user-readable table*_program_master_report.json— table data and provenance*_broadcast_segment_report.pdf— thumbnail-led visual report*_broadcast_segment_report.json— thumbnail selections and evidence*_qc.json— all structural, timecode, thumbnail, PDF, and source-hash checks*_run.json— bundle index and effective configuration*_segment_probes/and*_broadcast_segment_report_thumbnails/— visual evidence
Present the Markdown table and link the PDF, JSON report, manifest, and QC artifact. Never present a bundle whose QC did not pass.
Repeatability contract
Every run must make these choices explicit in the profile or command:
- selected relative video stream
- either one selected audio stream or
allaudio streams - embedded or file-relative timecode policy, including whether embedded timecode is mandatory
- OCR mode:
off,optional, orrequired, plus language and PSM - detector thresholds, fade policy, minimum overlap, and probe offset
- generic/raw label policy and whether every content row requires an editorial override
- expected minimum gap count and PDF layout policy
The manifest records the effective configuration, selected streams, authoritative video duration source, source SHA-256, profile SHA-256, tool versions, command, algorithm version, and schema version. Preserve these fields. Do not hand-edit detected timecodes or segment boundaries; rerun from a versioned profile.
The selected video stream is the duration authority. Segment intervals are start-inclusive and end-exclusive, begin at source frame zero, are contiguous, and cover the selected video through its exclusive final frame. The workflow fails closed on detector errors, missing required streams, a missing required tmcd, incomplete coverage, invalid overrides, missing thumbnails, or an invalid PDF.
Profile and policy
Start with profiles/broadcast-default.json. Copy it into the report bundle when a project needs custom thresholds or policies; give the copy a descriptive name and keep profile_version: "1.0".
Important examples:
{
"streams": {"video_stream": 0, "audio_policy": "all", "audio_stream": 0},
"timecode": {"mode": "embedded", "require_embedded": true, "file_fps": 29.97},
"ocr": {"mode": "required", "language": "eng", "psm": 6},
"labels": {"mode": "generic", "overrides": {}, "require_overrides_for_content": true},
"validation": {"min_gaps": 3}
}Use audio_policy: "single" only when that program mix is the declared structure authority. Use all when every audio track must be silent before a region is considered a separator. optional OCR permits a run without Tesseract and records availability; required fails instead of silently degrading.
For broadcast delivery, prefer embedded tmcd and set require_embedded: true when the source is expected to carry it. File-relative timecode is permitted only when the policy explicitly allows it. Never substitute nominal 30 fps for 30000/1001.
Editorial labels
Detection does not infer show-specific labels from segment numbers or hardcoded timecodes. Without overrides, content rows receive deterministic generic labels; readable OCR may supply a slate label. Gap rows are black+silent separator.
--label-overrides accepts any of:
{"0": "Color bars / reference tone", "4": "Program Act 1 (texted)"}{"labels": {"0": "Color bars / reference tone", "4": "Program Act 1 (texted)"}}It also accepts an existing report containing rows or segments with index and label. Unknown indices and empty labels fail. Set labels.require_overrides_for_content to true when all content names must be editorially approved. The report records the override file path and SHA-256.
Boundary and fade policy
The detector finds overlap between strict black picture and silence, then refines black edges at native-frame luma resolution:
- ffmpeg
blackdetectuses strict black (pix_th: 0.01,pic_th: 0.98by default). silencedetectruns on the declared audio stream policy.- Only overlaps meeting
min_overlapbecome structural gaps. - Hard cuts stay on the detected cut.
- A sustained luma ramp proves a fade; the mathematical black anchor is assigned to the adjoining content using
fade_handle_frames. - A terminal gap within two frames of the selected video end is extended to that exclusive end.
Silence gates structural gaps but does not erase a picture fade. This preserves the true start of content even when its first included fade frame is visually black. Keep boundary timecodes distinct from thumbnail selection.
Thumbnail PDF policy
Every content row has one source thumbnail at the start of the row. Gap rows use an intentional black+silent placeholder.
- Clean cut or intentional card: segment-start frame.
- Audio resumes while picture remains black: first picture after the proven black hold.
- Proven fade-up: first sustained upper-luma plateau within the configured search window.
The companion JSON records the chosen source frame, SMPTE timecode, offset from segment start, selection reason, and thumbnail path. Thus a faded content segment can correctly start at 01:00:00:00 while its report thumbnail shows the first fully established picture.
After generation, visually inspect every PDF page for clipped text, missing images, wrong row order, or illegible layout. Machine QC is mandatory but does not replace visual PDF QA.
Report format
The Markdown report contains every structural row through tail black:
| # | Type | Start TC | End TC | Duration | Label |
| 0 | content | 00:58:40:00 | 00:59:40:00 | 1:00 | Color bars / reference tone |
| 1 | gap | 00:59:40:00 | 00:59:45:00 | 5s | black+silent separator |
Use the report’s timecodes exactly. Do not add a speaker/context column. Do not omit pre-roll, slates, gaps, credits, post-program material, or tail black.
Diagnostic scripts
| Script | Purpose |
run_report.py | Canonical orchestration and final delivery bundle |
label_segments.py | Detect, refine, probe, label, timecode, provenance, manifest validation |
compile.py | Markdown and structured JSON from a validated manifest |
compile_pdf.py | Deterministic thumbnail-led PDF and companion JSON |
validate_report.py | Fail-closed final bundle QC |
self_test.py | Self-contained synthetic golden test, including deterministic PDF comparison |
doctor.py | Runtime readiness: binaries, profile, OCR policy, pinned dependencies |
detect_black_silence.py | Diagnostic black+silence overlap intervals |
detect_blacks.py | Diagnostic black intervals |
detect_silence.py | Diagnostic silence intervals |
schema.py | Manifest JSON schema |
analyze_structure.py | Legacy diagnostic; not a delivery workflow |
Run the golden test after changing code, thresholds, dependencies, schema, timecode, or rendering:
uv run <skill_directory>/scripts/self_test.py --work-dir /absolute/path/program-master-self-testIt synthesizes a tmcd MOV with hard cuts, black+silent gaps, a fade-up, and tail black; runs the complete workflow twice; verifies structure, embedded start timecode, fade thumbnail selection, source provenance, QC, PDF readability, and byte-identical deterministic PDFs.
Acceptance checks (agent must pass before delivery)
Same fail-closed bar as Human QC before delivery below. Minimum automated gates:
- Contract: exit 0,
ok: true, delivery paths exist. - Skill gate:
*_qc.jsonhaspassed: trueand no errors; never present a failing bundle. - Spot-check: first segment at frame zero, final row at video duration, review fade edges and every PDF page.
- On failure: fix overrides/thresholds and re-run
run_report.py.
Human QC before delivery
- Read
*_qc.json; require top-levelpassed: trueand no errors. - Confirm the source SHA-256 and selected stream policy match the requested master.
- Review every detected boundary and every
fade_in_detected/fade_out_detectededge against nearby source frames when the edit decision is consequential. - Confirm labels cover the intended content rows and come from the approved override file when required.
- Inspect every PDF page visually.
- Confirm the first segment begins at source frame zero and the final row ends at the authoritative video duration.
Do not use for
- hard cuts or camera shots inside content (use
shots) - subtitle or caption transcription (use
forced-narrative-exactorvision-analysis) - SCTE-only segmentation without black+silent structural evidence
Related skills: inspect, timecode, forced-narrative-exact, vision-analysis, and shots.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

