Communitygithub.com

David-Li0406/meta-skill-evolving

FFmpeg、WebRTC、ストリーミングによる音声・動画処理。トランスコード、フォーマット変換、リアルタイム通信、メディアパイプラインをカバーします。動画処理、ライブストリーミング、音声操作にお使いください。

meta-skill-evolving とは?

このスキルは、開発者がFFmpeg、WebRTC、ストリーミング技術を用いてオーディオおよびビデオ処理タスクを実行するための包括的なガイドです。基本的なフォーマット変換からアダプティブビットレートHLSやDASHストリーミングといった高度なワークフローまでをカバーし、PyAVやMoviePyを使用したPython統合の実践的な例も提供します。トランスコード、解像度変更、透かし追加、トリミング、連結、および音声正規化や波形生成を含む音声分析に対応しています。リアルタイムRTMPストリーミングの設定や非同期ビデオ処理パイプラインも含まれており、ライブ配信や拡張性のあるバックエンドサービスに最適です。このスキルはClaude Code、Cursor、CodexなどのAIエージェントとシームレスに連携し、チームのメディア処理ワークフローを効率化するのに役立ちます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/David-Li0406/meta-skill-evloving/tree/HEAD/skill-flow/data/skills-refined-36k/skillsmp/audio-video

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

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

ドキュメント

オーディオ・ビデオ処理スキル

音声・動画処理の完全ガイド。

クイックリファレンス

FFmpegコマンド一覧

タスクコマンド
変換ffmpeg -i input.mp4 output.webm
音声抽出ffmpeg -i video.mp4 -vn audio.mp3
サムネイルffmpeg -i video.mp4 -ss 5 -frames:v 1 thumb.jpg
リサイズffmpeg -i input.mp4 -vf scale=1280:720 output.mp4
圧縮ffmpeg -i input.mp4 -crf 28 output.mp4

一般的なフォーマット

ビデオ: MP4, WebM, MKV, AVI, MOV
オーディオ: MP3, AAC, WAV, FLAC, OGG
コーデック: H.264, H.265/HEVC, VP9, AV1

1. FFmpegの基本

インストール

# Ubuntu/Debian
sudo apt install ffmpeg

# macOS
brew install ffmpeg

# Windows (Chocolatey)
choco install ffmpeg

基本変換

# 動画フォーマット変換
ffmpeg -i input.avi output.mp4

# 音声フォーマット変換
ffmpeg -i input.wav output.mp3

# コーデック指定
ffmpeg -i input.mp4 -c:v libx264 -c:a aac output.mp4

動画品質制御

# CRF (Constant Rate Factor) - 0-51、低いほど高品質
ffmpeg -i input.mp4 -c:v libx264 -crf 23 output.mp4

# ビットレート制御
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M output.mp4

# 高品質のための2パスエンコード
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -pass 1 -f null /dev/null
ffmpeg -i input.mp4 -c:v libx264 -b:v 2M -pass 2 output.mp4

2. ビデオ処理

リサイズとスケーリング

# 特定解像度にスケーリング
ffmpeg -i input.mp4 -vf "scale=1920:1080" output.mp4

# アスペクト比を維持してスケーリング
ffmpeg -i input.mp4 -vf "scale=1280:-1" output.mp4  # 高さ自動
ffmpeg -i input.mp4 -vf "scale=-1:720" output.mp4   # 幅自動

# パディングでスケーリング(レターボックス)
ffmpeg -i input.mp4 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2" output.mp4

トリミングとカット

# タイムスタンプからタイムスタンプまでカット
ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy output.mp4

# 再生時間指定でカット
ffmpeg -i input.mp4 -ss 00:01:00 -t 30 -c copy output.mp4

# 高速シーク(-ssを入力前に指定)
ffmpeg -ss 00:01:00 -i input.mp4 -t 30 -c copy output.mp4

動画の連結

# ファイルリスト作成
echo "file 'video1.mp4'" > list.txt
echo "file 'video2.mp4'" >> list.txt
echo "file 'video3.mp4'" >> list.txt

# 連結
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4

ウォーターマーク追加

# 画像ウォーターマーク
ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=10:10" output.mp4

# 右下隅
ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=W-w-10:H-h-10" output.mp4

# テキストウォーターマーク
ffmpeg -i input.mp4 -vf "drawtext=text='Copyright':fontsize=24:fontcolor=white:x=10:y=10" output.mp4

速度調整

# 2倍速
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -filter:a "atempo=2.0" output.mp4

# 0.5倍速
ffmpeg -i input.mp4 -filter:v "setpts=2*PTS" -filter:a "atempo=0.5" output.mp4

3. 音声処理

音声抽出

# 音声トラック抽出
ffmpeg -i video.mp4 -vn -c:a copy audio.aac

# MP3に変換
ffmpeg -i video.mp4 -vn -c:a libmp3lame -q:a 2 audio.mp3

# 特定の音声ストリーム抽出
ffmpeg -i video.mp4 -map 0:a:0 -c copy audio.m4a

音声変換

# WAV → MP3
ffmpeg -i input.wav -c:a libmp3lame -b:a 320k output.mp3

# FLAC → MP3
ffmpeg -i input.flac -c:a libmp3lame -q:a 0 output.mp3

# MP3 → AAC
ffmpeg -i input.mp3 -c:a aac -b:a 256k output.m4a

音声ノーマライゼーション

# Loudnormフィルター (EBU R128)
ffmpeg -i input.mp3 -af loudnorm=I=-16:LRA=11:TP=-1.5 output.mp3

# 音量調整
ffmpeg -i input.mp3 -af "volume=2.0" output.mp3  # 2倍音量
ffmpeg -i input.mp3 -af "volume=0.5" output.mp3  # 半音量

# ピークノーマライゼーション
ffmpeg -i input.mp3 -af "acompressor" output.mp3

音声・動画のマージ

# 音声トラックを置き換え
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v -map 1:a output.mp4

# 動画に音声を追加(ミックス)
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -filter_complex "[0:a][1:a]amix=inputs=2:duration=first" output.mp4

4. サムネイルとスクリーンショット

単一サムネイル

# 特定時間
ffmpeg -i video.mp4 -ss 00:00:05 -frames:v 1 thumbnail.jpg

# 最高品質
ffmpeg -i video.mp4 -ss 00:00:05 -frames:v 1 -q:v 2 thumbnail.jpg

# 特定サイズ
ffmpeg -i video.mp4 -ss 00:00:05 -frames:v 1 -vf "scale=320:180" thumbnail.jpg

複数サムネイル

# N秒ごと
ffmpeg -i video.mp4 -vf "fps=1/10" thumbnails_%03d.jpg  # 10秒ごと

# 特定数のサムネイル
ffmpeg -i video.mp4 -vf "select='not(mod(n,300))'" -vsync vfr thumb_%03d.jpg

# サムネイルスプライト/グリッド
ffmpeg -i video.mp4 -vf "fps=1/10,scale=160:90,tile=10x10" sprite.jpg

GIF作成

# シンプルGIF
ffmpeg -i video.mp4 -ss 0 -t 5 -vf "fps=10,scale=320:-1" output.gif

# パレット付き高品質GIF
ffmpeg -i video.mp4 -ss 0 -t 5 -vf "fps=10,scale=320:-1:flags=lanczos,palettegen" palette.png
ffmpeg -i video.mp4 -i palette.png -ss 0 -t 5 -filter_complex "[0:v]fps=10,scale=320:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif

5. ストリーミングフォーマット

HLS (HTTP Live Streaming)

# HLS生成
ffmpeg -i input.mp4 \
  -c:v libx264 -c:a aac \
  -hls_time 10 \
  -hls_list_size 0 \
  -hls_segment_filename "segment_%03d.ts" \
  output.m3u8

# アダプティブビットレートHLS
ffmpeg -i input.mp4 \
  -filter_complex "[0:v]split=3[v1][v2][v3];[v1]scale=1920:1080[v1out];[v2]scale=1280:720[v2out];[v3]scale=854:480[v3out]" \
  -map "[v1out]" -c:v:0 libx264 -b:v:0 5M \
  -map "[v2out]" -c:v:1 libx264 -b:v:1 2M \
  -map "[v3out]" -c:v:2 libx264 -b:v:2 1M \
  -map 0:a -c:a aac -b:a 128k \
  -var_stream_map "v:0,a:0 v:1,a:0 v:2,a:0" \
  -master_pl_name master.m3u8 \
  -hls_time 6 \
  -hls_segment_filename "v%v/segment_%03d.ts" \
  v%v/index.m3u8

DASH (Dynamic Adaptive Streaming)

ffmpeg -i input.mp4 \
  -c:v libx264 -c:a aac \
  -f dash \
  -init_seg_name "init-\$RepresentationID\$.m4s" \
  -media_seg_name "chunk-\$RepresentationID\$-\$Number%05d\$.m4s" \
  output.mpd

6. Python統合

PyAV (FFmpegバインディング)

import av

def transcode_video(input_path, output_path, target_codec='libx264'):
    input_container = av.open(input_path)
    output_container = av.open(output_path, 'w')

    # 入力ストリームを取得
    video_stream = input_container.streams.video[0]
    audio_stream = input_container.streams.audio[0] if input_container.streams.audio else None

    # 出力ストリームを作成
    output_video = output_container.add_stream(target_codec, rate=video_stream.average_rate)
    output_video.width = video_stream.width
    output_video.height = video_stream.height
    output_video.pix_fmt = 'yuv420p'

    if audio_stream:
        output_audio = output_container.add_stream('aac', rate=audio_stream.rate)

    for packet in input_container.demux():
        if packet.stream.type == 'video':
            for frame in packet.decode():
                for out_packet in output_video.encode(frame):
                    output_container.mux(out_packet)
        elif packet.stream.type == 'audio' and audio_stream:
            for frame in packet.decode():
                for out_packet in output_audio.encode(frame):
                    output_container.mux(out_packet)

    # エンコーダーをフラッシュ
    for packet in output_video.encode():
        output_container.mux(packet)

    output_container.close()
    input_container.close()

MoviePy

from moviepy.editor import VideoFileClip, concatenate_videoclips, TextClip, CompositeVideoClip

def process_video(input_path, output_path):
    # 動画を読み込み
    clip = VideoFileClip(input_path)

    # トリミング
    trimmed = clip.subclip(10, 60)  # 10秒から60秒

    # リサイズ
    resized = trimmed.resize(height=720)

    # テキストオーバーレイ追加
    txt_clip = TextClip("Hello World", fontsize=50, color='white')
    txt_clip = txt_clip.set_position('center').set_duration(5)

    # 合成
    final = CompositeVideoClip([resized, txt_clip])

    # エクスポート
    final.write_videofile(
        output_path,
        codec='libx264',
        audio_codec='aac'
    )

    clip.close()

def create_thumbnail(video_path, output_path, time=5):
    clip = VideoFileClip(video_path)
    frame = clip.get_frame(time)
    clip.save_frame(output_path, t=time)
    clip.close()

def concatenate_videos(video_paths, output_path):
    clips = [VideoFileClip(path) for path in video_paths]
    final = concatenate_videoclips(clips)
    final.write_videofile(output_path)
    for clip in clips:
        clip.close()

FFmpegサブプロセス

import subprocess
import json

def get_video_info(video_path):
    """ffprobeを使用してビデオメタデータを取得"""
    cmd = [
        'ffprobe',
        '-v', 'quiet',
        '-print_format', 'json',
        '-show_format',
        '-show_streams',
        video_path
    ]

    result = subprocess.run(cmd, capture_output=True, text=True)
    return json.loads(result.stdout)

def transcode_video(input_path, output_path, options=None):
    """FFmpegでビデオをトランスコード"""
    cmd = ['ffmpeg', '-i', input_path]

    if options:
        if 'video_codec' in options:
            cmd.extend(['-c:v', options['video_codec']])
        if 'audio_codec' in options:
            cmd.extend(['-c:a', options['audio_codec']])
        if 'crf' in options:
            cmd.extend(['-crf', str(options['crf'])])
        if 'resolution' in options:
            cmd.extend(['-vf', f"scale={options['resolution']}"])

    cmd.extend(['-y', output_path])

    result = subprocess.run(cmd, capture_output=True, text=True)

    if result.returncode != 0:
        raise Exception(f"FFmpeg error: {result.stderr}")

    return True

def generate_hls(input_path, output_dir):
    """HLSストリームを生成"""
    import os
    os.makedirs(output_dir, exist_ok=True)

    cmd = [
        'ffmpeg', '-i', input_path,
        '-c:v', 'libx264',
        '-c:a', 'aac',
        '-hls_time', '10',
        '-hls_list_size', '0',
        '-hls_segment_filename', f'{output_dir}/segment_%03d.ts',
        f'{output_dir}/index.m3u8'
    ]

    subprocess.run(cmd, check=True)

7. ライブストリーミング

RTMPサーバー (nginx-rtmp)

# nginx.conf
rtmp {
    server {
        listen 1935;

        application live {
            live on;
            record off;

            # HLS出力
            hls on;
            hls_path /var/www/hls;
            hls_fragment 3;
            hls_playlist_length 60;
        }
    }
}

RTMPへのストリーム

# ファイルをRTMPにストリーム
ffmpeg -re -i input.mp4 -c copy -f flv rtmp://server/live/stream

# ウェブカメラをストリーム
ffmpeg -f v4l2 -i /dev/video0 -f alsa -i hw:0 \
  -c:v libx264 -preset veryfast -b:v 2M \
  -c:a aac -b:a 128k \
  -f flv rtmp://server/live/stream

# YouTubeにストリーム
ffmpeg -i input.mp4 \
  -c:v libx264 -preset medium -b:v 4M \
  -c:a aac -b:a 128k \
  -f flv rtmp://a.rtmp.youtube.com/live2/YOUR_STREAM_KEY

8. ビデオ処理パイプライン

Celeryを使用した非同期処理

from celery import Celery
import os

celery = Celery('video_tasks')

@celery.task
def process_upload(video_id, input_path):
    """完全なビデオ処理パイプライン"""
    output_dir = f'/videos/{video_id}'
    os.makedirs(output_dir, exist_ok=True)

    # サムネイル生成
    generate_thumbnail.delay(video_id, input_path, f'{output_dir}/thumb.jpg')

    # 複数解像度にトランスコード
    resolutions = [
        ('1080p', '1920:1080', '5M'),
        ('720p', '1280:720', '2.5M'),
        ('480p', '854:480', '1M'),
    ]

    for name, scale, bitrate in resolutions:
        transcode_resolution.delay(
            video_id, input_path,
            f'{output_dir}/{name}.mp4',
            scale, bitrate
        )

    # HLS生成
    generate_hls.delay(video_id, input_path, f'{output_dir}/hls')

@celery.task
def generate_thumbnail(video_id, input_path, output_path):
    cmd = [
        'ffmpeg', '-i', input_path,
        '-ss', '5', '-frames:v', '1',
        '-vf', 'scale=320:-1',
        output_path
    ]
    subprocess.run(cmd, check=True)

@celery.task
def transcode_resolution(video_id, input_path, output_path, scale, bitrate):
    cmd = [
        'ffmpeg', '-i', input_path,
        '-c:v', 'libx264', '-b:v', bitrate,
        '-vf', f'scale={scale}',
        '-c:a', 'aac', '-b:a', '128k',
        output_path
    ]
    subprocess.run(cmd, check=True)

9. 音声分析

波形生成

import librosa
import librosa.display
import matplotlib.pyplot as plt
import numpy as np

def generate_waveform(audio_path, output_path):
    """波形画像を生成"""
    y, sr = librosa.load(audio_path)

    plt.figure(figsize=(14, 5))
    librosa.display.waveshow(y, sr=sr)
    plt.title('波形')
    plt.savefig(output_path, dpi=150, bbox_inches='tight')
    plt.close()

def generate_spectrogram(audio_path, output_path):
    """スペクトログラム画像を生成"""
    y, sr = librosa.load(audio_path)
    D = librosa.stft(y)
    S_db = librosa.amplitude_to_db(np.abs(D), ref=np.max)

    plt.figure(figsize=(14, 5))
    librosa.display.specshow(S_db, sr=sr, x_axis='time', y_axis='hz')
    plt.colorbar(format='%+2.0f dB')
    plt.title('スペクトログラム')
    plt.savefig(output_path, dpi=150, bbox_inches='tight')
    plt.close()

10. ベストプラクティス

エンコーディングプリセット

# Web最適化MP4
ffmpeg -i input.mp4 \
  -c:v libx264 -preset slow -crf 22 \
  -c:a aac -b:a 128k \
  -movflags +faststart \
  output.mp4

# アーカイブ品質
ffmpeg -i input.mp4 \
  -c:v libx264 -preset veryslow -crf 18 \
  -c:a flac \
  archive.mkv

# モバイル最適化
ffmpeg -i input.mp4 \
  -c:v libx264 -preset fast -crf 28 \
  -vf "scale='min(720,iw)':-2" \
  -c:a aac -b:a 96k \
  mobile.mp4

ベストプラクティス

  1. ハードウェアアクセラレーションを使用 - NVENC、VAAPI、VideoToolbox
  2. Web最適化 - faststartフラグ

…

[翻訳のため一部省略]

Individual skills in this repo

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

David-Li0406/meta-skill-evloving

Browser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.

David-Li0406/meta-skill-evloving

Create technical diagrams using Mermaid syntax for architecture, sequences, ERDs, flowcharts, and state machines. Use for visualizing system design, data flows, and processes. Triggers: diagram, mermaid, architecture diagram, sequence diagram, flowchart, ERD, entity relationship, state diagram, C4 model, component diagram, visualize, draw.

David-Li0406/meta-skill-evloving

Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks

David-Li0406/meta-skill-evloving

Complete color manipulation and green screen effects system. PROACTIVELY activate for: (1) Green screen/chromakey removal, (2) Color grading with LUTs, (3) Color correction (levels, curves, white balance), (4) Colorkey/color removal effects, (5) Hue/saturation manipulation, (6) Color space conversions (BT.709, BT.2020, HDR), (7) Color isolation effects, (8) Teal and orange look, (9) Vintage/film looks, (10) Color keying for transparency. Provides: chromakey and colorkey filters, LUT application (lut3d), curves and levels adjustment, color balance, selective color manipulation, color space handling, HDR tone mapping, professional color grading chains.

David-Li0406/meta-skill-evloving

Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.

David-Li0406/meta-skill-evloving

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

David-Li0406/meta-skill-evloving

Build with OpenAI's stateless APIs - Chat Completions (GPT-5, GPT-4o), Embeddings, Images (DALL-E 3), Audio (Whisper + TTS), and Moderation. Includes Node.js SDK and fetch-based approaches for Cloudflare Workers. Use when: implementing chat completions with GPT-5/GPT-4o, streaming responses with SSE, using function calling/tools, creating structured outputs with JSON schemas, generating embeddings for RAG (text-embedding-3-small/large), generating images with DALL-E 3, editing images with GPT-Image-1, transcribing audio with Whisper, synthesizing speech with TTS (11 voices), moderating content (11 safety categories), or troubleshooting rate limits (429), invalid API keys (401), function calling failures, streaming parse errors, embeddings dimension mismatches, or token limit exceeded.

David-Li0406/meta-skill-evloving

Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

David-Li0406/meta-skill-evloving

Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

David-Li0406/meta-skill-evloving

Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas

David-Li0406/meta-skill-evloving

Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.

David-Li0406/meta-skill-evloving

Best practices for Remotion - Video creation in React

David-Li0406/meta-skill-evloving

Provides bidirectional translation (Chinese/English), grammar checking, and sentence polishing. Supports specific tense constraints, context-aware tone adjustment, and natural expression optimization. Outputs direct text without formatting.

David-Li0406/meta-skill-evloving

指导如何通过自定义注解(如@Unicom)标识Dubbo接口,利用BeanDefinitionRegistryPostProcessor在启动时扫描并动态注册ReferenceBean,实现RPC调用的封装。

David-Li0406/meta-skill-evloving

生成Python脚本,利用FFmpeg将图片序列按3x3布局合并,或将合并图拆分。要求使用subprocess模块执行命令,并支持用户交互式输入路径。

David-Li0406/meta-skill-evloving

SOP for extracting and analyzing promotional activity details, handling time formatting, location mapping, payment logic, and step-by-step process validation.

David-Li0406/meta-skill-evloving

Specializes in creating TikTok short video scripts using an anthropomorphic 'Chef' perspective to explain wildlife food chains and survival environments, utilizing real field footage.

David-Li0406/meta-skill-evloving

针对TikTok平台,以拟人化视角(如动物作为厨师)创作系列短视频脚本。重点介绍野生动物、食物链及生态环境,要求使用野外实拍素材,风格幽默且具有教育意义。

David-Li0406/meta-skill-evloving

Generates KWL (Know, Want to know, Learned) charts for educational videos, specifically BrainPOP, using simple 7th-grade language and short, concise bullet points.

David-Li0406/meta-skill-evloving

Tracks complex, multi-session work using the Beads issue tracker and dependency graphs, and provides persistent memory that survives conversation compaction. Use when work spans multiple sessions, has complex dependencies, or needs persistent context across compaction cycles. Trigger with phrases like "create task for", "what's ready to work on", "show task", "track this work", "what's blocking", or "update status".

関連スキル