Communitygithub.com

Biznomad/agent-skills

FFmpeg を使用した動画・音声処理。形式変換、リサイズ、圧縮、音声抽出、Remotion 向けアセット準備に利用します。GIF を MP4 に変換、動画のリサイズ、音声抽出、ファイル圧縮など、あらゆるメディア変換タスクをトリガーとして実行できます。

agent-skills とは?

このスキルは、FFmpeg を活用して動画・音声ファイルを効率的に処理するための包括的なガイドです。主に Remotion プロジェクト向けに設計されており、GIF から MP4 への変換、動画のリサイズ・圧縮、音声抽出・形式変換、トリミング、速度変更、連結、フェード効果などの基本操作をカバーします。各コマンドには、最適な結果を得るためのフラグの意味や品質設定の目安が詳細に説明されています。また、速度変更における FFmpeg と Remotion の使い分けや、Remotion レンダリング後のプラットフォーム別最適化(YouTube、Twitter/X、LinkedIn、Web 埋め込みなど)の具体的な手順も提供。よくあるエラーとその対処法もまとめられており、初心者から上級者まで幅広く役立つ実用的な内容です。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Biznomad/agent-skills/tree/HEAD/ffmpeg

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

動画制作のための FFmpeg

FFmpeg は動画・音声処理に欠かせないツールです。このスキルでは、Remotion 動画プロジェクトでよく使われる操作を解説します。

クイックリファレンス

GIF から MP4 へ(Remotion 互換)

ffmpeg -i input.gif -movflags faststart -pix_fmt yuv420p \
  -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" output.mp4

各フラグの意味:

  • -movflags faststart - Web ストリーミングのためにメタデータをファイル先頭に移動
  • -pix_fmt yuv420p - ほとんどのプレーヤーとの互換性を確保
  • scale=trunc(...) - 偶数サイズに強制(多くのコーデックで必須)

動画のリサイズ

# 1920x1080 に(アスペクト比維持、黒帯追加)
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output.mp4

# 1920x1080 に(トリミングして画面いっぱいに)
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080" output.mp4

# 幅を指定して高さは自動
ffmpeg -i input.mp4 -vf "scale=1280:-2" output.mp4

動画の圧縮

# 高品質、小さめファイル(CRF 23 がデフォルト、数値が小さいほど高品質)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4

# Web プレビュー向け高圧縮
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset fast -c:a aac -b:a 96k output.mp4

# ファイルサイズ指定(例:60秒動画で約10MB = 約1.3Mbps)
ffmpeg -i input.mp4 -c:v libx264 -b:v 1300k -c:a aac -b:a 128k output.mp4

音声の抽出

# MP3 に抽出
ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 2 output.mp3

# AAC に抽出
ffmpeg -i input.mp4 -vn -acodec aac -b:a 192k output.m4a

# WAV に抽出(非圧縮)
ffmpeg -i input.mp4 -vn output.wav

音声形式の変換

# M4A から MP3(ElevenLabs の音声サンプルなど)
ffmpeg -i input.m4a -codec:a libmp3lame -qscale:a 2 output.mp3

# WAV から MP3
ffmpeg -i input.wav -codec:a libmp3lame -b:a 192k output.mp3

# 音量調整
ffmpeg -i input.mp3 -filter:a "volume=1.5" output.mp3

動画の切り抜き / カット

# タイムスタンプから指定時間分カット(推奨、信頼性高い)
ffmpeg -i input.mp4 -ss 00:00:30 -t 00:00:15 -c:v libx264 -c:a aac output.mp4

# タイムスタンプからタイムスタンプまでカット
ffmpeg -i input.mp4 -ss 00:00:30 -to 00:00:45 -c:v libx264 -c:a aac output.mp4

# ストリームコピー(高速だがカット箇所でフレームが失われる可能性あり)
# ソースにキーフレームが頻繁にある場合のみ使用
ffmpeg -i input.mp4 -ss 00:00:30 -t 00:00:15 -c copy output.mp4

注意: カットには再エンコードを推奨します。ストリームコピー(-c copy)は、シークポイントがキーフレームと一致しない場合、映像が無音で欠落することがあります。

速度変更(早送り / スロー)

# 2倍速(映像と音声)
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4

# 0.5倍速(スローモーション)
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]" -map "[v]" -map "[a]" output.mp4

# 映像のみ(音声なし)
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4

動画の連結

# ファイルリスト作成
# bash
# ffmpeg の concat デマルチプレクサ用のテキストファイルを作成
echo "file 'clip1.mp4'" > list.txt
echo "file 'clip2.mp4'" >> list.txt
echo "file 'clip3.mp4'" >> list.txt

# 連結(同一コーデック・解像度)
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4

# 再エンコードしながら連結(異なるソースの場合)
ffmpeg -f concat -safe 0 -i list.txt -c:v libx264 -c:a aac output.mp4

フェードイン / フェードアウトの追加

# 最初の1秒にフェードイン、最後の1秒にフェードアウト(30fps 動画)
ffmpeg -i input.mp4 -vf "fade=t=in:st=0:d=1,fade=t=out:st=9:d=1" -c:a copy output.mp4

# 音声フェード
ffmpeg -i input.mp4 -af "afade=t=in:st=0:d=1,afade=t=out:st=9:d=1" -c:v copy output.mp4

動画情報の取得

# 長さ、解像度、コーデック情報
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4

# 詳細情報
ffprobe -v quiet -print_format json -show_format -show_streams input.mp4

Remotion 固有のパターン

Remotion 向け動画速度調整

FFmpeg を使うべきか、Remotion の playbackRate を使うべきか:

シナリオFFmpeg を使用Remotion を使用
一定速度 (1.5x, 2x)どちらでも可✅ より簡単
極端な速度 (>4x または <0.25x)✅ より信頼性高い問題が発生する可能性あり
可変速度(時間とともに加速)✅ 事前処理複雑な回避策が必要
完璧な音声同期が必要✅ 保証される通常は問題ない
デモの長さをナレーションに合わせる✅ 事前計算実行時調整

Remotion の制限: playbackRate は一定でなければなりません。playbackRate={interpolate(frame, [0, 100], [1, 5])} のような動的補間は、Remotion がフレームを個別に評価するため、正常に動作しません。

# デモをシーンに合わせて高速化(例:60秒のデモを20秒に = 3倍速)
ffmpeg -i demo-raw.mp4 \
  -filter_complex "[0:v]setpts=0.333*PTS[v];[0:a]atempo=3.0[a]" \
  -map "[v]" -map "[a]" \
  public/demos/demo-fast.mp4

# 強調のためのスローモーション(0.5倍速)
ffmpeg -i action.mp4 \
  -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]" \
  -map "[v]" -map "[a]" \
  public/demos/action-slow.mp4

# 音声なしで高速化(画面録画でよく使う)
ffmpeg -i demo.mp4 -filter:v "setpts=0.5*PTS" -an public/demos/demo-2x.mp4

# タイムラプス風(10倍速、音声削除)
ffmpeg -i long-demo.mp4 -filter:v "setpts=0.1*PTS" -an public/demos/timelapse.mp4

速度係数の計算:

  • X 秒の動画を Y 秒のシーンに収める場合: 速度 = X / Y
  • setpts の乗数 = 1 / 速度(例:3倍速なら setpts=0.333*PTS)
  • atempo の値 = 速度(例:3倍速なら atempo=3.0)

極端な速度(音声 >2倍): atempo フィルターを連結(各フィルターは 0.5~2.0 の範囲に制限):

# 4倍速音声
-filter_complex "[0:a]atempo=2.0,atempo=2.0[a]"

# 8倍速音声
-filter_complex "[0:a]atempo=2.0,atempo=2.0,atempo=2.0[a]"

Remotion 向けデモ録画の準備

# 標準 1080p、30fps、Remotion 対応
ffmpeg -i raw-recording.mp4 \
  -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,fps=30" \
  -c:v libx264 -crf 18 -preset slow \
  -c:a aac -b:a 192k \
  -movflags faststart \
  public/demos/demo.mp4

画面録画から Remotion アセットへ

# iPhone / iPad の録画から(通常 60fps、解像度は様々)
ffmpeg -i iphone-recording.mov \
  -vf "scale=1920:-2,fps=30" \
  -c:v libx264 -crf 20 \
  -an \
  public/demos/mobile-demo.mp4

GIF のバッチ変換

for f in assets/*.gif; do
  ffmpeg -i "$f" -movflags faststart -pix_fmt yuv420p \
    -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" \
    "public/demos/$(basename "$f" .gif).mp4"
done

よくある問題

「高さが2で割り切れない」

スケールフィルターを追加: -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2"

ブラウザで動画が再生されない

以下を使用: -movflags faststart -pix_fmt yuv420p -c:v libx264

速度変更後に音声がずれる

filter_complex と atempo を使用: -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]"

ファイルが大きすぎる

CRF 値を上げる(23→28)か、解像度を下げる

品質ガイドライン

用途CRFプリセット備考
アーカイブ / マスター18slow最高品質、大容量
プロダクション20-22mediumバランス良好
Web / プレビュー23-25fast小さめファイル
下書き / 簡易版28+veryfast高速エンコード

プラットフォーム別出力最適化

Remotion で動画をレンダリングした後(通常 out/video.mp4)、FFmpeg を使って各配信プラットフォーム向けに最適化します。

ワークフロー統合

Remotion レンダリング(マスター)     FFmpeg 最適化          プラットフォームアップロード
       ↓                            ↓                       ↓
   out/video.mp4  ────────→  out/video-youtube.mp4  ───→  YouTube
                  ────────→  out/video-twitter.mp4  ───→  Twitter/X
                  ────────→  out/video-linkedin.mp4 ───→  LinkedIn
                  ────────→  out/video-web.mp4      ───→  Webサイト埋め込み

YouTube(推奨設定)

YouTube はすべてを再エンコードするため、高品質でアップロード:

# YouTube 最適化(1080p)
ffmpeg -i out/video.mp4 \
  -c:v libx264 -preset slow -crf 18 \
  -profile:v high -level 4.0 \
  -bf 2 -g 30 \
  -c:a aac -b:a 192k -ar 48000 \
  -movflags +faststart \
  out/video-youtube.mp4

# YouTube Shorts(縦長 1080x1920)
ffmpeg -i out/video.mp4 \
  -vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2" \
  -c:v libx264 -crf 18 -c:a aac -b:a 192k \
  out/video-shorts.mp4

Twitter / X

Twitter には厳しい制限があります: 最大140秒、512MB、1920x1200:

# Twitter 最適化(高速アップロードのため 15MB 以下を目標)
ffmpeg -i out/video.mp4 \
  -c:v libx264 -preset medium -crf 24 \
  -profile:v main -level 3.1 \
  -vf "scale='min(1280,iw)':'min(720,ih)':force_original_aspect_ratio=decrease" \
  -c:a aac -b:a 128k -ar 44100 \
  -movflags +faststart \
  -fs 15M \
  out/video-twitter.mp4

# ファイルサイズと長さを確認
ffprobe -v error -show_entries format=duration,size -of csv=p=0 out/video-twitter.mp4

LinkedIn

LinkedIn は AAC 音声付き MP4 を推奨、最大10分:

# LinkedIn 最適化
ffmpeg -i out/video.mp4 \
  -c:v libx264 -preset medium -crf 22 \
  -profile:v main \
  -vf "scale='min(1920,iw)':'min(1080,ih)':force_original_aspect_ratio=decrease" \
  -c:a aac -b:a 192k -ar 48000 \
  -movflags +faststart \
  out/video-linkedin.mp4

Web サイト / 埋め込み(高速読み込み最適化)

# Web 最適化 MP4(小さなファイル、プログレッシブ読み込み)
ffmpeg -i out/video.mp4 \
  -c:v libx264 -preset medium -crf 26 \
  -profile:v baseline -level 3.0 \
  -vf "scale=1280:720" \
  -c:a aac -b:a 128k \
  -movflags +faststart \
  out/video-web.mp4

# WebM 代替(圧縮効率が高く、ブラウザ対応範囲が広い)
ffmpeg -i out/video.mp4 \
  -c:v libvpx-vp9 -crf 30 -b:v 0 \
  -vf "scale=1280:720" \
  -c:a libopus -b:a 128k \
  -deadline good \
  out/video-web.webm

GIF(プレビュー / サムネイル用)

# 高品質 GIF(最初の5秒)
ffmpeg -i out/video.mp4 -t 5 \
  -vf "fps=15,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
  out/preview.gif

# 小さめファイルの GIF
ffmpeg -i out/video.mp4 -t 3 \
  -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
  out/preview-small.gif

プラットフォーム要件クイックリファレンス

プラットフォーム最大解像度最大サイズ最大長さ音声
YouTube8K256GB12時間AAC 48kHz
Twitter/X1920x1200512MB140秒AAC 44.1kHz
LinkedIn4096x23045GB10分AAC 48kHz
Instagram フィード1080x13504GB60秒AAC 48kHz
Instagram リール1080x19204GB90秒AAC 48kHz
TikTok1080x1920287MB10分AAC

全プラットフォーム向け一括エクスポート

#!/bin/bash
# ファイル名: export-all-platforms.sh
INPUT="out/video.mp4"

# YouTube(高品質)
ffmpeg -i "$INPUT" -c:v libx264 -preset slow -crf 18 \
  -c:a aac -b:a 192k -movflags +faststart \
  out/video-youtube.mp4

# Twitter(圧縮)
ffmpeg -i "$INPUT" -c:v libx264 -crf 24 \
  -vf "scale='min(1280,iw)':'-2'" \
  -c:a aac -b:a 128k -movflags +faststart \
  out/video-twitter.mp4

# LinkedIn
ffmpeg -i "$INPUT" -c:v libx264 -crf 22 \
  -c:a aac -b:a 192k -movflags +faststart \
  out/video-linkedin.mp4

# Web 埋め込み(小)
ffmpeg -i "$INPUT" -c:v libx264 -crf 26 \
  -vf "scale=1280:720" \
  -c:a aac -b:a 128k -movflags +faststart \
  out/video-web.mp4

# 日本語メッセージ
echo "エクスポート完了:"
ls -lh out/video-*.mp4

エラー処理

動画処理でよくあるエラーと修正方法:

# FFmpeg が成功したか確認
ffmpeg -i input.mp4 -c:v libx264 output.mp4 && echo "Success" || echo "Failed: check input file"

# 出力ファイルが再生可能か検証
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of csv=p=0 output.mp4

# 詳細なエラー情報を取得
ffmpeg -v error -i input.mp4 -f null - 2>&1 | head -20

よくあるエラーとその対処

エラー原因修正
"No such file"入力パスが間違っているパスを確認、スペースがある場合は引用符で囲む
"Invalid data"入力ファイルが破損ソースを再ダウンロードまたは再録画
"height not divisible by 2"奇数サイズtrunc 付きスケールフィルターを追加
"encoder not found"コーデックが見つからない全てのコーデックを含む FFmpeg をインストール
Output 0 bytes警告なしの失敗ffmpeg 出力全体を確認

フィードバックとコントリビューション

このスキルに不足している情報がある、または改善できる点がありましたら:

  • コマンドが足りない? 何が必要だったか教えてください
  • エラーを見つけた? 何が間違っているか教えてください
  • コントリビューションしたい? 以下の方法をお手伝いします:
    1. このスキルを改善してアップデート
    2. github.com/digitalsamba/claude-code-video-toolkit へのプルリクエスト作成

「このスキルを改善」と言っていただければ、.claude/skills/ffmpeg/SKILL.md の更新をガイドします。

Individual skills in this repo

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

Biznomad/agent-skills

Landing page quality assessment for paid advertising campaigns. Evaluates message match, page speed, mobile experience, trust signals, form optimization, and conversion rate potential. Use when user says "landing page", "post-click experience", "landing page audit", "conversion rate", or "landing page optimization".

Biznomad/agent-skills

TikTok Ads deep analysis covering creative quality, tracking, bidding, campaign structure, and TikTok Shop. Evaluates 25 checks with emphasis on creative-first strategy, safe zone compliance, and Smart+ campaigns. Use when user says "TikTok Ads", "TikTok marketing", "TikTok Shop", "Spark Ads", "Smart+", or "TikTok campaign".

Biznomad/agent-skills

YouTube Ads specific analysis covering campaign types, creative quality, audience targeting, and measurement. Evaluates video ad performance across skippable, non-skippable, bumper, Shorts, and Demand Gen formats. Use when user says "YouTube Ads", "video ads", "pre-roll", "bumper ads", "YouTube campaign", or "Shorts ads".

Biznomad/agent-skills

Help users get promoted at work. Use when someone is preparing for a promotion conversation, building their case for advancement, trying to understand what's blocking their promotion, or figuring out how to get to the next level in their career.

Biznomad/agent-skills

CSS animation adapter patterns for HyperFrames. Use when authoring CSS keyframes, animation-delay based timing, animation-fill-mode, animation-play-state, or CSS-only motion that HyperFrames must seek deterministically during preview and rendering.

Biznomad/agent-skills

Read-only queue dashboard for workspace-aware ship. Shows which VERSION slots are currently claimed by open PRs, which sibling Conductor workspaces have WIP work likely to ship soon, and what slot /ship would pick next. No mutations — just a snapshot. Use when asked to "landing report", "what's in the queue", "show me open PRs", or "which version do I claim next". (gstack)

Biznomad/agent-skills

HyperFrames CLI dev loop — `npx hyperframes` for scaffolding (init), validation (lint, inspect), preview, render, and environment troubleshooting (doctor, browser, info, upgrade). Use when running any of these commands or troubleshooting the HyperFrames build/render environment. For asset preprocessing commands (`tts`, `transcribe`, `remove-background`), invoke the `hyperframes-media` skill instead.

Biznomad/agent-skills

Asset preprocessing for HyperFrames compositions — text-to-speech narration (Kokoro), audio/video transcription (Whisper), and background removal for transparent overlays (u2net). Use when generating voiceover from text, transcribing speech for captions, removing the background from a video or image to use as a transparent overlay, choosing a TTS voice or whisper model, or chaining these (TTS → transcribe → captions). Each command downloads its own model on first run.

Biznomad/agent-skills

Install and wire registry blocks and components into HyperFrames compositions. Use when running hyperframes add, installing a block or component, wiring an installed item into index.html, or working with hyperframes.json. Covers the add command, install locations, block sub-composition wiring, component snippet merging, and registry discovery.

Biznomad/agent-skills

Create video compositions, animations, title cards, overlays, captions, voiceovers, audio-reactive visuals, and scene transitions in HyperFrames HTML. Use when asked to build any HTML-based video content, add captions or subtitles synced to audio, generate text-to-speech narration, create audio-reactive animation (beat sync, glow, pulse driven by music), add animated text highlighting (marker sweeps, hand-drawn circles, burst lines, scribble, sketchout), or add transitions between scenes (crossfades, wipes, reveals, shader transitions). Covers composition authoring, timing, media, and the full video production workflow. For dev-loop CLI commands (init, lint, inspect, preview, render) see the hyperframes-cli skill; for asset preprocessing commands (tts, transcribe, remove-background) see the hyperframes-media skill.

Biznomad/agent-skills

Still-to-video conversion guide: model selection, motion prompting, and camera movement. Covers Wan 2.5 i2v, Seedance, Fabric, Grok Video with when to use each. Use for: animating images, creating video from stills, adding motion, product animations. Triggers: image to video, i2v, animate image, still to video, add motion to image, image animation, photo to video, animate still, wan i2v, image2video, bring image to life, animate photo, motion from image

Biznomad/agent-skills

>- The Landing Page Audit skill performs comprehensive evaluations of post-click experiences, combining technical performance analysis with conversion rate optimization (CRO) assessment.

Biznomad/agent-skills

Write high-converting landing page copy using proven frameworks like PAS (Problem-Agitate-Solution), AIDA, and StoryBrand. Creates headlines, value propositions, CTAs, and full page sections optimized for conversion. Use when users need landing page copy, sales page content, or marketing website text.

Biznomad/agent-skills

Optimize landing pages for higher conversion rates using proven frameworks and design patterns. Use when designing, reviewing, or improving landing pages, hero sections, pricing pages, CTAs, or when the user asks about conversion optimization.

Biznomad/agent-skills

Read-only queue dashboard for workspace-aware ship. (gstack)

Biznomad/agent-skills

Building promotion cases, brag documents, tracking wins, and self-advocacy for career advancement. Use when preparing for promotions, documenting accomplishments, or building your case for advancement.

Biznomad/agent-skills

Best practices for Remotion - Video creation in React

Biznomad/agent-skills

Translate an existing Remotion (React-based) video composition into a HyperFrames HTML composition. Use ONLY when the user explicitly asks to port, convert, migrate, translate, or rewrite a Remotion composition as HyperFrames (e.g. "port my Remotion project to HyperFrames"). Do NOT use when (a) authoring a NEW HyperFrames composition (even if A/B-testing a Remotion video); (b) Remotion is mentioned in passing; (c) Remotion code is shared as reference, not for translation; (d) the user wants "the same video as my Remotion one" without explicitly asking to migrate the source — treat as a fresh HyperFrames build. When in doubt, default to the `hyperframes` skill. Detects unsupported patterns (useState, useEffect side effects, async calculateMetadata, third-party React component libraries, `@remotion/lambda`) and recommends the runtime interop escape hatch instead of a lossy translation.

Biznomad/agent-skills

Produce programmable videos with Remotion using scene planning, asset orchestration, and validation gates for automated, brand-consistent video content.

Biznomad/agent-skills

Reviews animation and motion code against a high craft bar derived from Emil Kowalski's design engineering philosophy. Default to flagging; approval is earned.

関連スキル