Communitygithub.com

FFmpeg

FFmpeg はメディア処理のための万能ツールです。ほぼすべてのオーディオ/ビデオ形式、コーデック、コンテナを扱えます。このスキルは、形式変換、コーデックトランスコード、トリミング、結合、フィルタリング、圧縮、サムネイル抽出、字幕埋め込み、オーディオ正規化、GIF作成、ウォーターマーク追加、yt-dlp や gallery-dl とのパイプライン連携をカバーします。

FFmpeg とは?

FFmpeg スキルは、メディア処理における最も広範で強力なツールを提供します。コマンドラインからすべてのオーディオ・ビデオ操作を実行でき、形式変換、コーデックトランスコード、トリミング、結合、フィルタリング、圧縮、サムネイル抽出、字幕埋め込み、オーディオ正規化、GIF作成、ウォーターマーク追加などをカバーします。また、yt-dlp や gallery-dl などのツールとのパイプライン統合も可能です。このスキルは、初心者から上級者まであらゆる開発者やAIエージェントユーザーにとって不可欠であり、メディアファイルの操作を自動化・効率化できます。具体的には、WebMからMP4への変換、CRF(Constant Rate Factor)を使った品質制御、ストリームコピーによるロスレス処理、ffprobe を使ったメディア情報の取得、バッチ処理など、実践的なコマンド例を豊富に含んでいます。対象プラットフォームは、Ubuntu/Debian、macOS、その他Unix系OSで動作します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/TerminalSkills/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 から H.264)
ffmpeg -i input.mov -c:v libx264 -crf 18 -preset slow -c:a aac output.mp4

# 任意の形式 → ウェブ最適化 MP4(faststart 付き)
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: サムネイルとスクリーンショット

# タイムスタンプから1枚のスクリーンショット
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° 反時計回り

# 動画のトリミング(幅:高さ: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つの動画に結合してください。」

エージェントは以下の処理を行います:

  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 を使用して入力形式を理解し、不必要な再エンコードを避けてください。
  • バッチ操作では、ディレクトリ全体に実行する前にまず1つのファイルでコマンドをテストしてください。
  • シングルパスエンコードでは、ビットレートモードよりも CRF モードを優先してください。様々なコンテンツタイプで一貫した品質が得られます。

Individual skills in this repo

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

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル