Agent Skillsbenchflow-ai/skillsbench › ffmpeg-video-editing

ffmpeg-video-editing

GitHub

用于FFmpeg视频编辑,支持截取、拼接、移除片段及重编码。适用于mp4/mkv等格式,提供命令行与Python批量处理方案,实现精准剪辑与高效多段合并。

tasks-extra/video-filler-word-remover/environment/skills/ffmpeg-video-editing/SKILL.md benchflow-ai/skillsbench

Trigger Scenarios

用户需要剪辑或截取视频片段 用户需要将多个视频片段合并 用户需要从视频中删除特定时间段 用户提到ffmpeg或视频编辑工具

Install

npx skills add benchflow-ai/skillsbench --skill ffmpeg-video-editing -g -y
More Options

Non-standard path

npx skills add https://github.com/benchflow-ai/skillsbench/tree/main/tasks-extra/video-filler-word-remover/environment/skills/ffmpeg-video-editing -g -y

Use without installing

npx skills use benchflow-ai/skillsbench@ffmpeg-video-editing

指定 Agent (Claude Code)

npx skills add benchflow-ai/skillsbench --skill ffmpeg-video-editing -a claude-code -g -y

安装 repo 全部 skill

npx skills add benchflow-ai/skillsbench --all -g -y

预览 repo 内 skill

npx skills add benchflow-ai/skillsbench --list

SKILL.md

Frontmatter
{
    "name": "ffmpeg-video-editing",
    "description": "Video editing with ffmpeg including cutting, trimming, concatenating segments, and re-encoding. Use when working with video files (.mp4, .mkv, .avi) for: removing segments, joining clips, extracting portions, or any video manipulation task."
}

FFmpeg Video Editing

Cutting Video Segments

Extract a portion (keep segment)

# Extract from start_time to end_time
ffmpeg -i input.mp4 -ss START -to END -c copy output.mp4

# With re-encoding for frame-accurate cuts
ffmpeg -i input.mp4 -ss START -to END -c:v libx264 -c:a aac output.mp4

Remove a segment (cut out middle)

To remove a segment, split into parts and concatenate:

# 1. Extract before the cut
ffmpeg -i input.mp4 -to CUT_START -c copy part1.mp4

# 2. Extract after the cut  
ffmpeg -i input.mp4 -ss CUT_END -c copy part2.mp4

# 3. Concatenate
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4

Concatenating Multiple Segments

Using concat demuxer (recommended for same-codec files)

Create a file list (segments.txt):

file 'segment1.mp4'
file 'segment2.mp4'
file 'segment3.mp4'

Then concatenate:

ffmpeg -f concat -safe 0 -i segments.txt -c copy output.mp4

Using filter_complex (for re-encoding)

ffmpeg -i seg1.mp4 -i seg2.mp4 -i seg3.mp4 \
  -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a]concat=n=3:v=1:a=1[v][a]" \
  -map "[v]" -map "[a]" output.mp4

Removing Multiple Segments (Batch)

For removing many short segments (like filler words), the efficient approach:

  1. Calculate the "keep" segments (inverse of remove segments)
  2. Extract each keep segment
  3. Concatenate all keep segments
import subprocess
import os

def remove_segments(input_file, segments_to_remove, output_file):
    """
    segments_to_remove: list of (start, end) tuples in seconds
    """
    # Get video duration
    result = subprocess.run([
        'ffprobe', '-v', 'error', '-show_entries', 'format=duration',
        '-of', 'default=noprint_wrappers=1:nokey=1', input_file
    ], capture_output=True, text=True)
    duration = float(result.stdout.strip())

    # Sort segments and merge overlapping
    segments = sorted(segments_to_remove)

    # Calculate keep segments (gaps between remove segments)
    keep_segments = []
    current_pos = 0.0

    for start, end in segments:
        if start > current_pos:
            keep_segments.append((current_pos, start))
        current_pos = max(current_pos, end)

    if current_pos < duration:
        keep_segments.append((current_pos, duration))

    # Extract each keep segment
    temp_files = []
    for i, (start, end) in enumerate(keep_segments):
        temp_file = f'/tmp/seg_{i:04d}.mp4'
        subprocess.run([
            'ffmpeg', '-y', '-i', input_file,
            '-ss', str(start), '-to', str(end),
            '-c', 'copy', temp_file
        ], check=True)
        temp_files.append(temp_file)

    # Create concat list
    list_file = '/tmp/concat_list.txt'
    with open(list_file, 'w') as f:
        for temp_file in temp_files:
            f.write(f"file '{temp_file}'\n")

    # Concatenate
    subprocess.run([
        'ffmpeg', '-y', '-f', 'concat', '-safe', '0',
        '-i', list_file, '-c', 'copy', output_file
    ], check=True)

    # Cleanup
    for f in temp_files:
        os.remove(f)
    os.remove(list_file)

Common Issues

Audio/Video sync problems

  • Use -c copy only when cutting at keyframes
  • For precise cuts, re-encode: -c:v libx264 -c:a aac

Gaps or glitches at cut points

  • Ensure segments don't overlap
  • Small buffer (0.01s) between segments can help

Getting video duration

ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4

Version History

  • 9a1f4dd Current 2026-07-24 16:38

Same Skill Collection

.agents/skills/skill-creator/SKILL.md
.agents/skills/skillsbench/SKILL.md
.agents/skills/task-creator/SKILL.md
tasks-extra/cobol-gl-batch-reconcile/environment/skills/comp3-packed-decimal/SKILL.md
tasks-extra/cobol-gl-batch-reconcile/environment/skills/ebcdic-overpunch-decoding/SKILL.md
tasks-extra/cobol-gl-batch-reconcile/environment/skills/gl-posting-codes/SKILL.md
tasks-extra/cobol-gl-batch-reconcile/environment/skills/gnucobol-mainframe-batch/SKILL.md
tasks-extra/diff-transformer_impl/environment/skills/attention-variants-from-papers/SKILL.md
tasks-extra/diff-transformer_impl/environment/skills/modal-gpu/SKILL.md
tasks-extra/find-topk-similiar-chemicals/environment/skills/pdf/SKILL.md
tasks-extra/find-topk-similiar-chemicals/environment/skills/pubchem-database/SKILL.md
tasks-extra/find-topk-similiar-chemicals/environment/skills/rdkit/SKILL.md
tasks-extra/gh-repo-analytics/environment/skills/gh-cli/SKILL.md
tasks-extra/gpu-cluster-online-scheduling/environment/skills/fragmentation-aware-packing/SKILL.md
tasks-extra/gpu-cluster-online-scheduling/environment/skills/multi-resource-allocation-validation/SKILL.md
tasks-extra/gpu-cluster-online-scheduling/environment/skills/online-resource-scheduling/SKILL.md
tasks-extra/mhc-layer-impl/environment/skills/mhc-algorithm/SKILL.md
tasks-extra/mhc-layer-impl/environment/skills/modal-gpu/SKILL.md
tasks-extra/mhc-layer-impl/environment/skills/nanogpt-training/SKILL.md
tasks-extra/nda-playbook-review/environment/skills/nda-clause-taxonomy/SKILL.md
tasks-extra/nda-playbook-review/environment/skills/xlsx-parsing/SKILL.md
tasks-extra/pedestrian-traffic-counting/environment/skills/gemini-count-in-video/SKILL.md
tasks-extra/pedestrian-traffic-counting/environment/skills/gemini-video-understanding/SKILL.md
tasks-extra/pedestrian-traffic-counting/environment/skills/gpt-multimodal/SKILL.md
tasks-extra/pedestrian-traffic-counting/environment/skills/video-frame-extraction/SKILL.md
tasks-extra/pg-essay-to-audiobook/environment/skills/audiobook/SKILL.md
tasks-extra/pg-essay-to-audiobook/environment/skills/elevenlabs-tts/SKILL.md
tasks-extra/pg-essay-to-audiobook/environment/skills/gtts/SKILL.md
tasks-extra/pg-essay-to-audiobook/environment/skills/openai-tts/SKILL.md
tasks-extra/scheduling-email-assistant/environment/skills/gmail-skill/SKILL.md
tasks-extra/speaker-diarization-subtitles/environment/skills/automatic-speech-recognition/SKILL.md
tasks-extra/speaker-diarization-subtitles/environment/skills/multimodal-fusion/SKILL.md
tasks-extra/speaker-diarization-subtitles/environment/skills/speaker-clustering/SKILL.md
tasks-extra/speaker-diarization-subtitles/environment/skills/voice-activity-detection/SKILL.md
tasks-extra/taxonomy-tree-merge/environment/skills/hierarchical-taxonomy-clustering/SKILL.md
tasks-extra/video-filler-word-remover/environment/skills/filler-word-processing/SKILL.md
tasks-extra/video-filler-word-remover/environment/skills/whisper-transcription/SKILL.md
tasks-extra/video-tutorial-indexer/environment/skills/speech-to-text/SKILL.md
tasks/3d-scan-calc/environment/skills/mesh-analysis/SKILL.md
tasks/ada-bathroom-plan-repair/environment/skills/ada-plan-view-accessibility/SKILL.md
tasks/ada-bathroom-plan-repair/environment/skills/architectural-dxf-extraction/SKILL.md
tasks/ada-bathroom-plan-repair/environment/skills/geometric-layout-repair/SKILL.md
tasks/adaptive-cruise-control/environment/skills/csv-processing/SKILL.md
tasks/adaptive-cruise-control/environment/skills/pid-controller/SKILL.md
tasks/adaptive-cruise-control/environment/skills/simulation-metrics/SKILL.md
tasks/adaptive-cruise-control/environment/skills/vehicle-dynamics/SKILL.md
tasks/adaptive-cruise-control/environment/skills/yaml-config/SKILL.md
tasks/azure-bgp-oscillation-route-leak/environment/skills/azure-bgp/SKILL.md
tasks/bike-rebalance/environment/skills/geospatial-routing-data/SKILL.md

Metadata

Files
0
Version
9a1f4dd
Hash
4e33abec
Indexed
2026-07-24 16:38

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-07 18:16
浙ICP备14020137号-1 $방문자$