agentleFS
ckorhonenckorhonen/claude-skills/skills/video-editor/SKILL.md

video-editor

Skill17 starsChanged 4 months agoMITView on GitHub

Expert guidance for video editing with ffmpeg, encoding best practices, and quality optimization. Use when working with video files, transcoding, remuxing, encoding settings, color spaces, or troubleshooting video quality issues.

19 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use brainstorm.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • nicolasestremSkill

    brainstorm

    Structured idea generation and solution exploration with systematic analysis.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. 0 are common, 12 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 12

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 12
  2. Distinctive:

    Rule of thumb: If you only need to change the container format, remux.

    line 41
  3. Very specific:

    Recommendation: Use slower for quality-focused encoding.

    line 129
  4. Distinctive:

    Check codec support on target device

    line 278
  5. Very specific:

    Verify file isn't corrupted: ffmpeg -v error -i file.mkv -f null -

    line 280
  6. Distinctive:

    Check color range (Limited vs.

    line 285
  7. Distinctive:

    Check color matrix (BT.709 vs.

    line 286
  8. Distinctive:

    Use slower preset for better compression

    line 292
  9. Distinctive:

    Consider x265 for better efficiency

    line 293
  10. Distinctive:

    Check if you're unnecessarily encoding (remux instead)

    line 294
  11. Distinctive:

    Use faster preset (but accept larger file)

    line 298
  12. Distinctive:

    Check if hardware encoding is acceptable for your use case

    line 299
  13. Distinctive:

    Ensure source isn't being decoded unnecessarily

    line 300
  14. Distinctive:

    Check source file for sync issues first

    line 304
  15. Very specific:

    Use -async 1 for audio sync correction

    line 305

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Video Editor - FFmpeg & Encoding Expert

Expert guidance for video editing, encoding, and processing with ffmpeg. This skill covers container formats, codecs, encoding best practices, and quality optimization for video production workflows.

When to Use This Skill

Use this skill when:

  • Encoding or transcoding video files
  • Converting between container formats (MKV, MP4, etc.)
  • Optimizing encoding settings for quality or file size
  • Troubleshooting video quality issues
  • Working with color spaces and color matrices
  • Hardsubbing or softsubbing videos
  • Preparing videos for specific platforms or devices
  • Understanding why a video looks wrong after processing

Core Concepts

Container vs. Codec

This distinction is critical. File extensions like .mkv or .mp4 are container formats that package already-compressed streams. The actual compression happens through codecs like H.264, H.265, VP9, or AV1.

ConceptWhat It IsExamples
ContainerWrapper that holds video/audio/subtitle streamsMKV, MP4, AVI, MOV, WebM
CodecAlgorithm that compresses/decompresses videoH.264, H.265/HEVC, VP9, AV1
EncoderSoftware that implements a codecx264, x265, libvpx, NVENC

Remuxing vs. Reencoding

OperationWhat It DoesQuality ImpactSpeed
RemuxingMoves streams between containers without re-compressionNone (lossless)Very fast
ReencodingDecodes and re-encodes video with new settingsAlways loses qualitySlow

Rule of thumb: If you only need to change the container format, remux. Only reencode when absolutely necessary.

Quality Principles

What "Quality" Actually Means

Video quality measures how closely the output resembles the source. Every processing step moves the video further from the original. There is no way to add quality - only preserve or lose it.

Common Misconceptions

MythReality
Higher resolution = better qualityResolution is just dimensions; a 720p video can look better than a 4K one
Higher bitrate = better qualityEncoder efficiency matters more; same quality at different sizes is possible
H.265 is always 50% smallerDepends on encoder settings; poorly-configured H.265 can be worse than H.264
Hardware encoding is fine for qualityHardware encoders (NVENC, QuickSync) sacrifice quality for speed
AI upscaling improves qualityUpscaling adds artificial detail that wasn't in the source

The Encoding Quality Hierarchy

From most to least important:

  1. Encoder settings (CRF, preset, tuning)
  2. Encoder choice (x264/x265 vs. hardware encoders)
  3. Codec (H.265 vs. H.264 vs. VP9)

Quick Reference: FFmpeg Commands

Remux (Change Container, No Quality Loss)

# MKV to MP4 (preserves all streams)
ffmpeg -i input.mkv -c copy output.mp4

# MP4 to MKV
ffmpeg -i input.mp4 -c copy output.mkv

Basic Encoding

# Encode with x264, copy audio
ffmpeg -i input.mkv -c:a copy -c:v libx264 -preset slower -crf 20 output.mkv

# Encode with x265
ffmpeg -i input.mkv -c:a copy -c:v libx265 -preset slower -crf 22 output.mkv

Quality-Focused Encoding

# High-quality x264 for animation
ffmpeg -i input.mkv -c:a copy -c:v libx264 -preset slower -crf 18 \
  -x264-params bframes=8 output.mkv

# High-quality x265
ffmpeg -i input.mkv -c:a copy -c:v libx265 -preset slower -crf 20 \
  -x265-params bframes=8 output.mkv

Encoding Settings Deep Dive

CRF (Constant Rate Factor)

CRF controls quality vs. file size tradeoff. Lower = higher quality, larger file.

CRF RangeQuality LevelTypical Use
0LosslessArchival, intermediate
15-18Visually losslessHigh-quality archival
19-23High qualityGeneral use, streaming
24-28Medium qualityWeb, mobile
29+Low qualityPreviews, thumbnails

Note: CRF values aren't directly comparable between encoders. x265 CRF 22 ≈ x264 CRF 20.

Preset

Presets control encoding speed vs. compression efficiency.

PresetSpeedFile SizeUse When
ultrafastFastestLargestLive streaming
fastFastLargeQuick transcodes
mediumModerateModerateDefault
slowSlowSmallerQuality-focused
slowerVery slowEven smallerRecommended for quality
veryslowExtremely slowSmallestMaximum compression

Recommendation: Use slower for quality-focused encoding. The difference between slower and veryslow is minimal for significant time cost.

Tune Options

TuneBest For
filmLive-action with film grain
animationCartoons, anime, flat areas
grainPreserve film grain
stillimageSlideshow, static content
fastdecodePlayback on weak devices
# Animation tuning
ffmpeg -i input.mkv -c:v libx264 -preset slower -crf 20 -tune animation output.mkv

Container-Specific Considerations

MKV (Matroska)

Pros:

  • Supports virtually any codec
  • Multiple audio/subtitle tracks
  • Chapter markers
  • Variable frame rate support

Cons:

  • Less compatible with some devices/software
  • Some streaming services don't accept it

MP4

Pros:

  • Universal compatibility
  • Web-friendly
  • Hardware decoder support everywhere

Cons:

  • Limited subtitle format support
  • Stricter codec requirements
  • Constant frame rate expected

Converting MKV to MP4 for Editing Software

Some editing software requires constant frame rate MP4. Use this two-pass approach:

# Step 1: Initial remux with timescale adjustment
ffmpeg -i input.mkv -c copy -video_track_timescale 24000 intermediate.mp4

# Step 2: Fix timestamps
ffmpeg -i intermediate.mp4 -c copy \
  -bsf:v "setts=dts=1001*round(DTS/1001):pts=1001*round(PTS/1001)" output.mp4

Color Space & Color Management

Understanding Color Metadata

Videos store colors in YCbCr format with metadata specifying:

  • Color matrix: How to convert YCbCr to RGB (BT.709, BT.601)
  • Color range: Limited (16-235) vs. Full (0-255)
  • Chroma location: Where color samples are positioned

Common Issues

SymptomLikely Cause
Washed out colorsWrong color range (Limited treated as Full)
Crushed blacks/blown whitesWrong color range (Full treated as Limited)
Greenish/pinkish tintWrong color matrix
Colors look "off" after encodeMismatched color metadata

Preserving Color Information

# Explicitly preserve color metadata
ffmpeg -i input.mkv -c:v libx264 -preset slower -crf 20 \
  -colorspace bt709 -color_primaries bt709 -color_trc bt709 output.mkv

Hardsubbing (Burning In Subtitles)

Using FFmpeg

# Hardsub from external subtitle file
ffmpeg -i input.mkv -vf "subtitles=subs.ass" -c:v libx264 -preset slower -crf 20 output.mkv

# Hardsub from embedded subtitle track
ffmpeg -i input.mkv -vf "subtitles=input.mkv:si=0" -c:v libx264 -preset slower -crf 20 output.mkv

Using mpv (Better for Complex Subtitles)

mpv handles complex ASS subtitles (styling, positioning) more accurately:

mpv --no-config input.mkv -o output.mkv \
  --audio=no \
  --ovc=libx264 \
  --ovcopts=preset=slower,crf=20,bframes=8

What to Avoid

Tools

ToolProblem
HandbrakeUnpredictable settings, hides important options
Online convertersQuality loss, privacy concerns
"AI upscalers"Add fake detail, move further from source
Windows built-in toolsPoor quality, limited options

Practices

PracticeWhy It's Bad
Unnecessary sharpeningAdds artifacts, moves from source
Upscaling to higher resolutionDoesn't add real detail
Multiple reencodesQuality loss compounds
Using NVENC for qualityHardware encoders prioritize speed over quality
Frame rate interpolationAdds fake frames with artifacts

Recommended Tools

Essential

ToolPurpose
ffmpegSwiss army knife for video processing
MediaInfoInspect video properties and metadata
mpvSuperior media player, encoding support
MKVToolNixGUI for MKV muxing operations

Specialized

ToolPurpose
AegisubSubtitle editing
HandBrakeSimple transcoding (use with caution)
yt-dlpDownload online videos

Troubleshooting

Video Won't Play

  1. Check codec support on target device
  2. Try remuxing to different container
  3. Verify file isn't corrupted: ffmpeg -v error -i file.mkv -f null -

Colors Look Wrong After Encoding

  1. Compare color metadata: mediainfo input.mkv vs. mediainfo output.mkv
  2. Check color range (Limited vs. Full)
  3. Check color matrix (BT.709 vs. BT.601)
  4. Explicitly set color parameters in ffmpeg command

File Size Too Large

  1. Increase CRF (e.g., 20 → 23)
  2. Use slower preset for better compression
  3. Consider x265 for better efficiency
  4. Check if you're unnecessarily encoding (remux instead)

Encoding Takes Forever

  1. Use faster preset (but accept larger file)
  2. Check if hardware encoding is acceptable for your use case
  3. Ensure source isn't being decoded unnecessarily

Audio/Video Out of Sync

  1. Check source file for sync issues first
  2. Use -async 1 for audio sync correction
  3. Try remuxing instead of reencoding

Examples

Archive a Blu-ray Rip

ffmpeg -i input.mkv -c:a copy -c:v libx265 -preset slower -crf 18 \
  -x265-params bframes=8 output.mkv

Prepare for YouTube Upload

ffmpeg -i input.mkv -c:a aac -b:a 384k -c:v libx264 -preset slower -crf 18 \
  -profile:v high -level 4.2 -pix_fmt yuv420p output.mp4

Quick Preview/Proxy

ffmpeg -i input.mkv -c:a aac -b:a 128k -c:v libx264 -preset fast -crf 28 \
  -vf scale=640:-2 output.mp4

Extract Audio Only

# Copy audio stream (no re-encoding)
ffmpeg -i input.mkv -vn -c:a copy output.mka

# Convert to MP3
ffmpeg -i input.mkv -vn -c:a libmp3lame -b:a 320k output.mp3

Trim Without Re-encoding

# Trim from 1:00 to 2:30
ffmpeg -i input.mkv -ss 00:01:00 -to 00:02:30 -c copy output.mkv

Resources

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.