segment-combiner
Combine multiple segment detection results into a normalized interval union. Use when you need to merge segments from different detectors, prepare removal lists for video processing, or consolidate detection outputs into a disjoint, sorted, clamped sequence.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- segment-combiner
- description
- Combine multiple segment detection results into a normalized interval union. Use when you need to merge segments from different detectors, prepare removal lists for video processing, or consolidate detection outputs into a disjoint, sorted, clamped sequence.
02 资源文件 1
- 脚本scripts/combine_segments.py3.8 KB
03 SKILL.md 正文
Segment Combiner
Combines multiple segment JSON files into a single, normalized unified segments file for video processing. The output is the interval union of all inputs, not a plain concatenation.
Use Cases
- Merging segments from multiple detectors (e.g., initial-silence + pauses)
- Consolidating detection results that may touch or overlap at boundaries
- Preparing unified input for video-processor that satisfies its precondition contract
Usage
python3 /root/.claude/skills/segment-combiner/scripts/combine_segments.py \
--segments /path/to/segments1.json /path/to/segments2.json \
--output /path/to/all_segments.json \
--total-duration 600.0
Parameters
--segments: One or more segment JSON files to combine--output: Path to output combined segments JSON--total-duration: Optional video duration in seconds. When provided, segment ends are clamped tototal_durationand starts are clamped to0. Strongly recommended when the output feedsvideo-processor, so the downstream precondition check cannot fail on out-of-range intervals.
Input Format
Each input file should have a segments array:
{
"segments": [
{"start": 0, "end": 221, "duration": 221},
{"start": 219, "end": 305, "duration": 86}
]
}
Output Format
{
"segments": [
{"start": 0, "end": 305, "duration": 305}
],
"total_segments": 1,
"total_duration_seconds": 305
}
Normalization post-conditions (contract)
The segments array returned by this skill is guaranteed to be a normalized
interval union. Downstream tools (notably video-processor) rely on these
properties and may refuse to proceed if they do not hold:
- Sorted by
startascending. - Clamped so every
start >= 0and, when--total-durationis given, everyend <= total_duration. Degenerate intervals withend <= startafter clamping are dropped. - Disjoint and non-touching: for consecutive segments
end[i] < start[i+1]. Any overlapping or touching input intervals (e.g., opening ending at221plus a pause starting at221or219) are merged into one. - Consistent duration: for every segment
duration == end - startafter merging. Durations are recomputed; inputdurationfields are not trusted.
These post-conditions are the mechanism this skill is responsible for; detector threshold tuning, start-time handoff, and min-duration inclusivity remain the responsibility of the respective detectors and must not be re-litigated here.
Dependencies
- Python 3.11+
Example
# Combine segments from multiple detectors into a normalized union
python3 /root/.claude/skills/segment-combiner/scripts/combine_segments.py \
--segments initial_silence.json pauses.json \
--total-duration 600 \
--output all_segments.json
Notes
- Output is the interval union: sorted, clamped to
[0, total_duration], with overlapping/touching intervals merged, and eachdurationrecomputed. - Compatible with
video-processor --remove-segmentsinput and satisfies its "sorted and non-overlapping" precondition by construction. - All input files must have a
segmentsarray.
04 同仓库更多 Skills
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms
video-frame-extraction
Extract frames from video files and save them as images using OpenCV
openai-vision
Analyze images and multi-frame sequences using OpenAI GPT vision models
image-ocr
Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms