Communitygithub.com

FFmpeg

트랜스코딩, 변환, 편집, 오디오 및 비디오 처리를 FFmpeg로 수행합니다. 사용자가 비디오 포맷 변환(webm→mp4, mkv→mp4), 오디오 추출, 비디오 압축, 클립 자르기, 비디오 연결, 자막 추가, 썸네일 생성, 필터 적용, 해상도 또는 비트레이트 변경, 미디어 재인코딩, GIF 생성, 워터마크 추가, 오디오 노멀라이즈, 미디어 스트리밍, 자동화된 미디어 처리 파이프라인 구축을 요청할 때 사용합니다.

FFmpeg란 무엇인가요?

FFmpeg는 오디오 및 비디오 포맷, 코덱, 컨테이너를 거의 모두 처리하는 미디어 처리용 스위스 아미 나이프입니다. 이 스킬은 포맷 변환, 코덱 트랜스코딩, 트리밍, 연결, 필터링, 압축, 썸네일 추출, 자막 삽입, 오디오 노멀라이즈, GIF 생성, 워터마킹 및 yt-dlp, gallery-dl과 같은 도구와의 파이프라인 통합을 다룹니다. 주로 CLI 환경에서 사용되며, Ubuntu/Debian, macOS 등에서 설치할 수 있고 `ffprobe`를 통해 미디어 정보를 분석한 후 처리합니다. 중요한 사용 사례로는 yt-dlp로 다운로드한 WebM 파일을 MP4(H.264+AAC)로 변환, 여러 클립을 하나의 하이라이트 릴로 연결, 배치 처리 스크립트를 통한 대량 변환 등이 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/ffmpeg

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

FFmpeg은(는) 무엇을 하나요?

개요

FFmpeg는 미디어 처리의 스위스 아미 나이프입니다. 거의 모든 오디오 및 비디오 포맷, 코덱, 컨테이너를 처리합니다. 이 스킬은 포맷 변환, 코덱 트랜스코딩, 트리밍, 연결, 필터링, 압축, 썸네일 추출, 자막 삽입, 오디오 노멀라이즈, GIF 생성, 워터마킹, yt-dlp 및 gallery-dl과 같은 도구와의 파이프라인 통합을 다룹니다.

지침

1단계: 설치

# Ubuntu/Debian
sudo apt install -y ffmpeg

# macOS
brew install ffmpeg

# 확인
ffmpeg -version
ffprobe -version   # 미디어 정보 도구, ffmpeg에 포함됨

2단계: 포맷 변환

가장 일반적인 작업 — 컨테이너 포맷과 코덱 간 변환.

# WebM → MP4 (H.264 + AAC로 재인코딩, 범용 호환성)
ffmpeg -i input.webm -c:v libx264 -c:a aac -movflags +faststart output.mp4

# WebM → MP4 (이미 H.264/AAC인 경우 스트림 복사 — 즉시, 품질 손실 없음)
ffmpeg -i input.webm -c copy output.mp4

# MKV → MP4 (스트림 복사, 재인코딩 없음)
ffmpeg -i input.mkv -c copy output.mp4

# AVI → MP4
ffmpeg -i input.avi -c:v libx264 -crf 23 -c:a aac -b:a 128k output.mp4

# MOV → MP4 (Apple ProRes to H.264)
ffmpeg -i input.mov -c:v libx264 -crf 18 -preset slow -c:a aac output.mp4

# 모든 포맷 → MP4 (웹 최적화 fast start 포함)
ffmpeg -i input.* -c:v libx264 -crf 23 -preset medium -c:a aac -movflags +faststart output.mp4

CRF (Constant Rate Factor): 품질을 제어합니다. 값이 낮을수록 더 나은 품질, 더 큰 파일.

  • 18: 시각적 무손실
  • 23: 기본값, 좋은 균형
  • 28: 더 작은 파일, 일부 품질 손실
  • 51: 최악의 품질

3단계: 오디오 작업

# 비디오에서 오디오 추출
ffmpeg -i video.mp4 -vn -c:a copy audio.aac          # 코덱 복사 (빠름)
ffmpeg -i video.mp4 -vn -c:a libmp3lame -q:a 2 audio.mp3  # MP3로 변환
ffmpeg -i video.mp4 -vn -c:a flac audio.flac          # 무손실 FLAC

# 오디오 포맷 간 변환
ffmpeg -i input.wav -c:a libmp3lame -b:a 320k output.mp3
ffmpeg -i input.mp3 -c:a libopus -b:a 128k output.opus
ffmpeg -i input.flac -c:a aac -b:a 256k output.m4a

# 오디오 볼륨 노멀라이즈
ffmpeg -i input.mp3 -af loudnorm=I=-16:LRA=11:TP=-1.5 output.mp3

# 샘플레이트 변경
ffmpeg -i input.wav -ar 44100 output.wav

# 비디오에 오디오 병합
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4

4단계: 자르기, 컷 및 연결

# 타임스탬프부터 지속 시간까지 자르기
ffmpeg -i input.mp4 -ss 00:01:30 -t 00:00:45 -c copy clip.mp4    # 1:30부터 45초

# 시작부터 끝 타임스탬프까지 자르기
ffmpeg -i input.mp4 -ss 00:05:00 -to 00:10:00 -c copy clip.mp4   # 5:00부터 10:00까지

# 처음 30초
ffmpeg -i input.mp4 -t 30 -c copy first30.mp4

# 파일 연결 (먼저 파일 목록 생성)
cat > filelist.txt << 'EOF'
file 'clip1.mp4'
file 'clip2.mp4'
file 'clip3.mp4'
EOF
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4

# 재인코딩을 통한 연결 (코덱이 다른 경우)
ffmpeg -f concat -safe 0 -i filelist.txt -c:v libx264 -c:a aac output.mp4

5단계: 해상도 및 압축

# 1080p로 리사이즈 (가로세로비 유지)
ffmpeg -i input.mp4 -vf "scale=-2:1080" -c:v libx264 -crf 23 -c:a copy output.mp4

# 720p로 리사이즈
ffmpeg -i input.mp4 -vf "scale=-2:720" -c:v libx264 -crf 23 -c:a copy output.mp4

# 특정 너비로 리사이즈 (높이 자동)
ffmpeg -i input.mp4 -vf "scale=1280:-2" output.mp4

# 공격적으로 압축 (더 작은 파일)
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset faster -c:a aac -b:a 96k small.mp4

# 대상 파일 크기를 위한 2패스 인코딩
ffmpeg -i input.mp4 -c:v libx264 -b:v 1M -pass 1 -an -f null /dev/null
ffmpeg -i input.mp4 -c:v libx264 -b:v 1M -pass 2 -c:a aac -b:a 128k output.mp4

# 프레임레이트 변경
ffmpeg -i input.mp4 -r 30 output.mp4

6단계: 썸네일 및 스크린샷

# 타임스탬프에서 단일 스크린샷
ffmpeg -i input.mp4 -ss 00:01:30 -frames:v 1 thumb.jpg

# 10초마다 스크린샷
ffmpeg -i input.mp4 -vf "fps=1/10" thumbs/frame_%04d.jpg

# 썸네일 그리드 (4x4 연락처 시트)
ffmpeg -i input.mp4 -vf "select='not(mod(n,300))',scale=320:-1,tile=4x4" -frames:v 1 grid.jpg

# 첫 번째 프레임 추출
ffmpeg -i input.mp4 -frames:v 1 first_frame.png

7단계: 자막

# 비디오에 자막 하드코딩 (하드 서브)
ffmpeg -i input.mp4 -vf "subtitles=subs.srt" output.mp4

# 스타일이 적용된 ASS/SSA 자막
ffmpeg -i input.mp4 -vf "ass=subs.ass" output.mp4

# 자막 트랙 추가 (소프트 서브, 사용자 전환 가능)
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s mov_text output.mp4

# 비디오에서 자막 추출
ffmpeg -i input.mkv -map 0:s:0 subs.srt

8단계: 필터 및 효과

# 비디오 세그먼트에서 GIF 생성
ffmpeg -i input.mp4 -ss 5 -t 3 -vf "fps=15,scale=480:-1:flags=lanczos" output.gif

# 팔레트를 이용한 고품질 GIF
ffmpeg -i input.mp4 -ss 5 -t 3 -vf "fps=15,scale=480:-1:flags=lanczos,palettegen" palette.png
ffmpeg -i input.mp4 -i palette.png -ss 5 -t 3 -lavfi "fps=15,scale=480:-1:flags=lanczos[v];[v][1:v]paletteuse" output.gif

# 워터마크 추가
ffmpeg -i input.mp4 -i watermark.png -filter_complex "overlay=W-w-10:H-h-10" output.mp4

# 속도 증가 / 감소
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" fast.mp4
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]" -map "[v]" -map "[a]" slow.mp4

# 비디오 회전
ffmpeg -i input.mp4 -vf "transpose=1" rotated.mp4    # 90° 시계 방향
ffmpeg -i input.mp4 -vf "transpose=2" rotated.mp4    # 90° 반시계 방향

# 비디오 자르기 (width:height:x:y)
ffmpeg -i input.mp4 -vf "crop=1280:720:0:180" cropped.mp4

# 페이드 인/아웃
ffmpeg -i input.mp4 -vf "fade=in:0:30,fade=out:870:30" -af "afade=in:0:30,afade=out:870:30" output.mp4

9단계: 미디어 정보

# 전체 미디어 정보
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4

# 지속 시간만
ffprobe -v quiet -show_entries format=duration -of csv=p=0 input.mp4

# 해상도
ffprobe -v quiet -select_streams v:0 -show_entries stream=width,height -of csv=p=0 input.mp4

# 코덱 정보
ffprobe -v quiet -select_streams v:0 -show_entries stream=codec_name -of csv=p=0 input.mp4

10단계: 배치 처리

# 모든 WebM 파일을 MP4로 변환
for f in *.webm; do
  ffmpeg -i "$f" -c:v libx264 -crf 23 -c:a aac "${f%.webm}.mp4"
done

# 디렉터리 내 모든 MP4 파일 압축
for f in *.mp4; do
  ffmpeg -i "$f" -c:v libx264 -crf 28 -preset fast -c:a aac "compressed_${f}"
done

# 모든 비디오에서 오디오 추출
for f in *.mp4; do
  ffmpeg -i "$f" -vn -c:a libmp3lame -q:a 2 "${f%.mp4}.mp3"
done

예제

예제 1: yt-dlp 다운로드를 WebM에서 MP4로 변환

사용자 프롬프트: "yt-dlp로 비디오를 다운로드했는데 모두 .webm 파일이에요. iPhone에서 재생할 수 있게 MP4로 변환해 주세요."

에이전트는 다음을 수행합니다:

  1. ffprobe를 사용하여 WebM 파일에 H.264+AAC가 포함되어 있는지(스트림 복사 가능) 또는 VP9+Opus(재인코딩 필요)인지 확인합니다.
  2. VP9/Opus 파일의 경우 실행: for f in *.webm; do ffmpeg -i "$f" -c:v libx264 -crf 23 -preset medium -c:a aac -movflags +faststart "${f%.webm}.mp4"; done
  3. -movflags +faststart 플래그는 메타데이터를 파일의 시작 부분으로 이동시켜 모바일 장치 및 웹 브라우저에서 즉시 재생할 수 있게 합니다.
  4. 변환 결과를 변환 전후 파일 크기와 함께 보고합니다.

예제 2: 여러 클립에서 하이라이트 릴 만들기

사용자 프롬프트: "컨퍼런스에서 찍은 5개의 비디오 클립이 있어요. 가장 좋은 부분을 잘라서 페이드 전환 효과와 함께 하나의 비디오로 합쳐 주세요."

에이전트는 다음을 수행합니다:

  1. -ss 및 -to 플래그로 각 클립을 지정된 타임스탬프에 맞게 자릅니다.
  2. 모든 클립을 동일한 코덱/해상도로 재인코딩합니다: ffmpeg -i clip.mp4 -c:v libx264 -crf 23 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,fade=in:0:15,fade=out:st=DURATION:d=0.5" -c:a aac -ar 44100 segment_N.mp4
  3. concat 파일 목록을 생성하고 병합합니다: ffmpeg -f concat -safe 0 -i filelist.txt -c copy highlight_reel.mp4

지침

  • yt-dlp 다운로드(보통 WebM/VP9+Opus)를 변환할 때는 최대 장치 호환성을 위해 항상 H.264+AAC로 재인코딩하세요. -c:v libx264 -crf 23 -c:a aac -movflags +faststart를 사용합니다.
  • 가능하면 재인코딩을 피하기 위해 스트림 복사(-c copy)를 사용하세요. 즉시 처리되며 무손실입니다. 코덱을 변경하거나 필터를 적용하거나 소스와 대상 컨테이너가 호환되지 않을 때만 재인코딩하세요.
  • 웹 또는 모바일 재생을 위해 MP4 파일을 만들 때는 항상 -movflags +faststart를 추가하세요. moov 원자를 파일 시작 부분으로 이동시켜 즉시 스트리밍이 가능합니다.
  • 처리 전에 ffprobe를 사용하여 입력 포맷을 이해하고 불필요한 재인코딩을 피하세요.
  • 배치 작업 시에는 전체 디렉터리에서 실행하기 전에 먼저 단일 파일로 명령을 테스트하세요.
  • 단일 패스 인코딩의 경우 비트레이트 모드보다 CRF 모드를 선호하세요. 다양한 콘텐츠 유형에서 일관된 품질을 제공합니다.

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

When the user wants to perform load testing, stress testing, or performance testing of APIs and websites using k6. Also use when the user mentions "k6," "load test," "performance test," "stress test," "spike test," "soak test," "thresholds," "virtual users," or "VUs." For browser-based testing, see selenium.

TerminalSkills/skills

>- Lovable (formerly GPT Engineer) is a browser-based AI app builder that turns a natural-language description into a working full-stack web app with a built-in backend, authentication, database and one-click publishing. Use when the user wants to prototype or ship a web app with Lovable, write effective Lovable prompts, connect Supabase or GitHub, review generated security rules, or move a Lovable project into their own editor.

관련 스킬