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.py5.3 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:
- Verify the input video exists and is readable (use
ffprobeto capture duration/streams for later 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, sort, clamp, and de-overlap all removal segments (follow the segment-combiner convention: intervals are
[start,end)and must be non-overlapping). - Process the original video with the combined segments to create the compressed video.
- 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;
- run
ffprobe(keep it bounded; use a short timeout in wrappers/scripts) on the compressed video and confirm it 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.
Use Cases
- Removing detected pauses and openings from videos
- Creating highlight reels by keeping only specific segments
- Batch processing multiple segment removals
Usage
python3 /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(s) containing segments to remove
Input Segment Format
Segments are removal intervals in seconds (use [start, end) convention):
{
"segments": [
{"start": 0, "end": 600, "duration": 600},
{"start": 610, "end": 613, "duration": 3}
]
}
Or multiple segment files (only safe when already disjoint / de-overlapped; prefer segment-combiner output when in doubt):
python3 /skills/video-processor/scripts/process_video.py \
--input video.mp4 \
--output output.mp4 \
--remove-segments opening.json pauses.json
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)
- Calculate keep segments (inverse of removal segments)
- Build ffmpeg filter to trim and concatenate
- Process video via ffmpeg filter_complex (libx264 + aac)
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 opening and pause removal
python3 /skills/video-processor/scripts/process_video.py \
--input /root/lecture.mp4 \
--output /root/compressed.mp4 \
--remove-segments /root/opening.json /root/pauses.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
- Assumes removal segments are sorted and non-overlapping; if detectors can overlap, fix upstream (e.g., pause
--start-timeafter opening) or normalize by merging before processing. - For automated verification scripts, keep subprocess calls bounded (e.g.,
subprocess.run(..., timeout=10)) to avoid long/hanging validations.
Tutorial (source of truth)
(tutorial body omitted per config)
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