video-processor
Process videos by removing segments and concatenating remaining parts. Use when you need to remove detected pauses/openings from videos, create highlight reels, or batch process segment removals using ffmpeg filter_complex.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- video-processor
- description
- Process videos by removing segments and concatenating remaining parts. Use when you need to remove detected pauses/openings from videos, create highlight reels, or batch process segment removals using ffmpeg filter_complex.
02 资源文件 1
- 脚本scripts/process_video.py8.4 KB
03 SKILL.md 正文
Video Segment Processor
Blocking terminal-result gate
For video-silence-remover, execution state is RED until terminal tool results confirm both required artifacts and every completion check below. While state is RED, every assistant response must include an actual terminal function call for the next incomplete pipeline action; status text may accompany that call.
A command written in prose, JSON, or a code block is still pending because it has no terminal result. Advance a step only after its real tool result returns. State becomes GREEN only after tool results confirm /root/compressed_video.mp4 and /root/compression_report.json; an ordinary final response is valid only in GREEN state.
Processes videos by removing specified segments and concatenating the remaining parts. Handles multiple removal segments efficiently using ffmpeg's filter_complex.
Mandatory end-to-end completion gate
For a silence-removal task, treat the available audio and video skills as one ordered pipeline. Continue issuing tool calls until both final artifacts pass the completion checks:
- Extract the input video's audio.
- Calculate the audio-energy sequence.
- Detect the non-teaching opening with the silence detector's time-aligned result, then start long-pause detection at that returned boundary. Run the documented detector defaults before considering any tuning.
- Combine all removal segments through
segment-combiner, which is the owner of the "sort, clamp, merge overlapping/touching, recompute duration" normalization contract. Pass--total-duration(the input video's ffprobe duration) so segments are clamped to the valid timeline. Do not hand-concatenate segment arrays into video-processor; always route them throughsegment-combinerso the normalized interval-union contract holds. - Process the original video with the combined segments to create the compressed video. Before building keep segments, verify the removal segments honor the combiner's contract (see "Removal-segment preconditions" below). On violation, re-run
segment-combinerwith--total-durationand feed the fresh output in; do not silently proceed. - Generate the task-format compression report from the actual original video, compressed video, and final segment list.
- Verify both outputs with tools and repair any failed check.
For video-silence-remover, completion requires both /root/compressed_video.mp4 and /root/compression_report.json. Before finishing, confirm that:
- both files exist and are non-empty;
ffprobecan read the compressed video and reports valid video and audio streams;- the JSON is parseable and contains
original_duration_seconds,compressed_duration_seconds,removed_duration_seconds,compression_percentage, andsegments_removed; - every removed segment has numeric
start < endandduration ≈ end - start, and the segments are sorted and non-overlapping; - the measured compressed duration agrees with the report and
original ≈ compressed + removed.
Each intermediate audio, energy, or segment file is a checkpoint, not the completion criterion. After deciding or describing the next action, perform it with a tool call. Finish only after the two final artifacts pass these checks.
Removal-segment preconditions (contract with segment-combiner)
process_video.py's calculate_keep_segments assumes a disjoint, monotonic
sequence: it advances current_time = seg['end'] per segment, and overlapping
or out-of-order inputs would make current_time regress and produce zero or
negative keep spans. The script therefore validates the following preconditions
on the loaded removal segments before building keep segments:
- every segment has numeric
start >= 0andend > start; - every segment ends within
[0, ffprobe_duration]of the input video; - segments are sorted by
startascending; - no two consecutive segments overlap or touch (
end[i] < start[i+1]).
These are exactly the post-conditions of segment-combiner. If any check fails,
abort and re-run segment-combiner with --total-duration set to the input
video's duration, then re-invoke video-processor with the fresh combined
file. Do not patch the segment list by hand inside this skill.
Use Cases
- Removing detected pauses and openings from videos
- Creating highlight reels by keeping only specific segments
- Batch processing multiple segment removals
Usage
python3 /root/.claude/skills/video-processor/scripts/process_video.py \
--input /path/to/input.mp4 \
--output /path/to/output.mp4 \
--remove-segments /path/to/segments.json
Parameters
--input: Path to input video file--output: Path to output video file--remove-segments: JSON file containing segments to remove (expected to be the normalized output ofsegment-combiner)
Input Segment Format
{
"segments": [
{"start": 0, "end": 600, "duration": 600},
{"start": 610, "end": 613, "duration": 3}
]
}
Or multiple segment files:
python3 /root/.claude/skills/video-processor/scripts/process_video.py \
--input video.mp4 \
--output output.mp4 \
--remove-segments opening.json pauses.json
When passing multiple files, each must already be normalized OR you must route
them through segment-combiner first; this skill does not re-run the
normalization, it only verifies the contract and fails fast on violation.
Output
Creates the processed video and a report JSON:
{
"original_duration": 3908.61,
"output_duration": 3078.61,
"removed_duration": 830.0,
"compression_percentage": 21.24,
"segments_removed": 91,
"segments_kept": 91
}
How It Works
- Load removal segments from JSON file(s)
- Verify preconditions (sorted, clamped, non-overlapping, non-touching)
- Calculate keep segments (inverse of removal segments)
- Build ffmpeg filter to trim and concatenate
- Process video using hardware-accelerated encoding
- Generate report with statistics
FFmpeg Filter Example
For 3 segments to keep:
[0:v]trim=start=600:end=610,setpts=PTS-STARTPTS[v0];
[0:a]atrim=start=600:end=610,asetpts=PTS-STARTPTS[a0];
[0:v]trim=start=613:end=1000,setpts=PTS-STARTPTS[v1];
[0:a]atrim=start=613:end=1000,asetpts=PTS-STARTPTS[a1];
[v0][v1]concat=n=2:v=1:a=0[outv];
[a0][a1]concat=n=2:v=0:a=1[outa]
Dependencies
- ffmpeg with libx264 and aac support
- Python 3.11+
Limitations
- Processing time: ~0.3× video duration (e.g., 20 min for 65 min video)
- Requires sufficient disk space (output ≈ 70-80% of input size)
- May have frame-accurate cuts (not sample-accurate)
Example
# Process video with normalized removal segments
python3 /root/.claude/skills/video-processor/scripts/process_video.py \
--input /root/lecture.mp4 \
--output /root/compressed.mp4 \
--remove-segments /root/all_segments.json
# Result: 65 min → 51 min (21.2% compression)
Performance Tips
- Use
-preset mediumfor balanced speed/quality - Use
-crf 23for good quality at reasonable size - Process on machines with 2+ CPU cores for faster encoding
Notes
- Preserves video quality using CRF encoding
- Maintains audio sync throughout
- Handles edge cases (segments at start/end of video)
- Generates detailed statistics for verification
- Precondition failures surface as a hard error so the pipeline re-invokes
segment-combinerinstead of silently producing an inconsistent compressed video
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