Communitygithub.com

NeverSight/learn-skills.dev

FFmpeg 命令集,用于视频/音频转换、裁剪、压缩和处理。当用户提到“ffmpeg”、“convert video”、“compress video”、“extract audio”、“trim video”、“gif from video”、“video codec”、“transcode”、“screen recording”、“merge videos”、“video to mp4”、“reduce file size” 或任何媒体处理任务时使用。

learn-skills.dev 是什么?

这是一个专注于 FFmpeg 工具的技能集,旨在帮助开发者和AI代理快速完成各种多媒体处理任务。它包含了从基础探测、格式转换、视频压缩、音频提取,到高级的裁剪拼接、GIF生成、屏幕录制和加速减速等功能,几乎覆盖了日常工作中90%的FFmpeg使用场景。该技能以大量即用命令行为核心,每个命令都附带了详细的参数说明和实际用例,用户可以直接复制粘贴使用。它支持 macOS、Linux(X11/Wayland)和 Windows 平台。其工作原理是直接调用系统安装的 FFmpeg 可执行文件,通过精心编排的参数组合实现预期效果,例如使用CRF模式控制视频质量与文件大小的平衡,或通过两步调色板生成高质量的 GIF。对于开发者而言,这大大减少了记忆复杂命令参数的时间,提高了媒体处理效率。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/NeverSight/learn-skills.dev/tree/HEAD/data/skills-md/1mangesh1/dev-skills-collection/ffmpeg

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

FFmpeg

探测与检查

# 显示所有流信息(编码器、分辨率、比特率、时长)
ffprobe -v error -show_format -show_streams input.mp4

# 单行摘要:时长、文件大小、比特率
ffprobe -v error -show_entries format=duration,size,bit_rate -of default=noprint_wrappers=1 input.mp4

# 显示视频分辨率和帧率
ffprobe -v error -select_streams v:0 -show_entries stream=width,height,r_frame_rate,codec_name -of csv=p=0 input.mp4

# 列出所有支持的编码器
ffmpeg -codecs

# 列出所有支持的格式
ffmpeg -formats

# 列出可用的编码器
ffmpeg -encoders

格式转换

# MP4 转 MKV(复制流,不重新编码——快速)
ffmpeg -i input.mp4 -c copy output.mkv

# MKV 转 MP4(如果编码器与 MP4 容器不兼容,则重新编码)
ffmpeg -i input.mkv -c:v libx264 -c:a aac output.mp4

# AVI 转 MP4
ffmpeg -i input.avi -c:v libx264 -c:a aac output.mp4

# MOV 转 MP4(常用于 iPhone 拍摄的视频)
ffmpeg -i input.mov -c:v libx264 -c:a aac -movflags +faststart output.mp4

# MP4 转 WebM(VP9 + Opus,用于网页)
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus output.webm

# 任意格式,让 FFmpeg 为目标容器自动选择编码器
ffmpeg -i input.avi output.mp4

压缩视频

# CRF 模式(恒定质量)。CRF 值越低,质量越好,文件越大。
# CRF 18 = 视觉无损,23 = 默认,28 = 文件较小但画质有损。
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4

# 更快的编码速度,更大的文件
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset fast -c:a copy output.mp4

# 更慢的编码速度,更小的文件(适用于存档)
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a aac output.mp4

# H.265,同等质量下文件减小约 50%(编码较慢)
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -preset medium -c:a aac output.mp4

# 针对特定文件大小(例如,60 秒视频限制 25 MB)
# 计算比特率:(25 * 8192) / 60 = 约 3413 kbps 总比特率。音频约减去 128。
ffmpeg -i input.mp4 -c:v libx264 -b:v 3285k -pass 1 -an -f null /dev/null && \
ffmpeg -i input.mp4 -c:v libx264 -b:v 3285k -pass 2 -c:a aac -b:a 128k output.mp4

提取音频

# 提取音频为 MP3
ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3

# 提取音频为 AAC(若已是 AAC,则直接复制)
ffmpeg -i input.mp4 -vn -c:a copy output.aac

# 提取音频为 WAV(未压缩)
ffmpeg -i input.mp4 -vn -c:a pcm_s16le output.wav

# 提取音频为 FLAC(无损)
ffmpeg -i input.mp4 -vn -c:a flac output.flac

音频格式转换

# WAV 转 MP3(VBR 质量 2,大约 190 kbps)
ffmpeg -i input.wav -c:a libmp3lame -q:a 2 output.mp3

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

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

# WAV 转 OGG Vorbis
ffmpeg -i input.wav -c:a libvorbis -q:a 5 output.ogg

# WAV 转 Opus(最佳质量与体积比)
ffmpeg -i input.wav -c:a libopus -b:a 128k output.opus

# 任意音频转 WAV(用于编辑或兼容性)
ffmpeg -i input.mp3 -c:a pcm_s16le -ar 44100 output.wav

裁剪与切割

# 从 00:01:30 切到 00:03:00,不重新编码(快速,但可能存在关键帧问题)
ffmpeg -ss 00:01:30 -to 00:03:00 -i input.mp4 -c copy output.mp4

# 裁剪时重新编码(帧精确)
ffmpeg -ss 00:01:30 -to 00:03:00 -i input.mp4 -c:v libx264 -c:a aac output.mp4

# 截取前 30 秒
ffmpeg -ss 0 -t 30 -i input.mp4 -c copy output.mp4

# 截取最后 30 秒(需要知道时长,或使用负起始值)
ffmpeg -sseof -30 -i input.mp4 -c copy output.mp4

# 移除前 10 秒
ffmpeg -ss 10 -i input.mp4 -c copy output.mp4

创建 GIF

# 基础 GIF(低质量,简单)
ffmpeg -i input.mp4 -vf "fps=10,scale=480:-1" output.gif

# 高质量 GIF,带调色板生成(两步)
ffmpeg -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,palettegen" palette.png && \
ffmpeg -i input.mp4 -i palette.png -lavfi "fps=15,scale=480:-1:flags=lanczos [x]; [x][1:v] paletteuse" output.gif

# 从特定片段生成 GIF(从 00:00:30 开始,时长 5 秒)
ffmpeg -ss 00:00:30 -t 5 -i input.mp4 -vf "fps=15,scale=480:-1:flags=lanczos,palettegen" palette.png && \
ffmpeg -ss 00:00:30 -t 5 -i input.mp4 -i palette.png -lavfi "fps=15,scale=480:-1:flags=lanczos [x]; [x][1:v] paletteuse" output.gif

缩放与调整尺寸

# 缩放到 1280x720
ffmpeg -i input.mp4 -vf "scale=1280:720" -c:a copy output.mp4

# 宽度缩放到 1280,保持宽高比(-1 自动计算,-2 确保偶数)
ffmpeg -i input.mp4 -vf "scale=1280:-2" -c:a copy output.mp4

# 缩放到原始尺寸的 50%
ffmpeg -i input.mp4 -vf "scale=iw/2:ih/2" -c:a copy output.mp4

# 适配 1920x1080 范围,保持宽高比(不放大)
ffmpeg -i input.mp4 -vf "scale='min(1920,iw)':'min(1080,ih)':force_original_aspect_ratio=decrease" -c:a copy output.mp4

字幕

# 硬编码字幕(烧录到视频中,始终可见)
ffmpeg -i input.mp4 -vf "subtitles=subs.srt" output.mp4

# 硬编码并自定义样式
ffmpeg -i input.mp4 -vf "subtitles=subs.srt:force_style='FontSize=24,PrimaryColour=&HFFFFFF'" output.mp4

# 软字幕(用户可以开关,MP4 格式)
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s mov_text output.mp4

# 软字幕(MKV 格式,支持更多字幕格式,包括 ASS)
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s srt output.mkv

# 从视频中提取字幕
ffmpeg -i input.mkv -map 0:s:0 output.srt

合并与拼接

# 拼接视频(要求相同编码器、分辨率、帧率)
# 首先创建一个文件列表:
# file 'part1.mp4'
# file 'part2.mp4'
# file 'part3.mp4'
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4

# 通过 shell 命令生成文件列表
for f in part*.mp4; do echo "file '$f'"; done > filelist.txt
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

# 将视频和音频从不同文件合并
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -shortest output.mp4

# 替换视频中的音频轨道
ffmpeg -i video.mp4 -i newaudio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4

提取帧

# 在特定时间戳提取一帧
ffmpeg -ss 00:01:30 -i input.mp4 -frames:v 1 frame.png

# 每秒提取一帧
ffmpeg -i input.mp4 -vf "fps=1" frames_%04d.png

# 每 10 秒提取一帧
ffmpeg -i input.mp4 -vf "fps=1/10" frames_%04d.png

# 提取所有帧(警告:会生成大量文件)
ffmpeg -i input.mp4 frames_%06d.png

# 创建缩略图拼贴(4x4 网格)
ffmpeg -i input.mp4 -vf "select='not(mod(n\,100))',scale=320:180,tile=4x4" -frames:v 1 thumbnails.png

屏幕录制

# macOS -- 录制全屏
ffmpeg -f avfoundation -framerate 30 -i "1:0" -c:v libx264 -preset ultrafast -crf 18 output.mp4

# macOS -- 列出可用设备
ffmpeg -f avfoundation -list_devices true -i ""

# macOS -- 录制屏幕和音频
ffmpeg -f avfoundation -framerate 30 -i "1:0" -c:v libx264 -preset ultrafast -c:a aac output.mp4

# Linux (X11) -- 录制全屏
ffmpeg -f x11grab -framerate 30 -video_size 1920x1080 -i :0.0 -c:v libx264 -preset ultrafast -crf 18 output.mp4

# Linux (X11) -- 录制指定区域(偏移量 x=100,y=200,尺寸 1280x720)
ffmpeg -f x11grab -framerate 30 -video_size 1280x720 -i :0.0+100,200 -c:v libx264 -preset ultrafast output.mp4

# Linux (PipeWire/Wayland) -- 使用 pipewire 屏幕捕获
# Wayland 不支持 x11grab。请使用 pw-record 或 OBS + pipewire。

加速与减速

# 视频加速 2 倍(丢弃音频)
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -an output.mp4

# 视频和音频同时加速 2 倍
ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4

# 视频和音频同时减速 2 倍
ffmpeg -i input.mp4 -vf "setpts=2.0*PTS" -af "atempo=0.5" output.mp4

# 加速 4 倍(串联 atempo 滤镜;每个 atempo 支持 0.5-2.0 范围)
ffmpeg -i input.mp4 -vf "setpts=0.25*PTS" -af "atempo=2.0,atempo=2.0" output.mp4

移除音频

# 剥离音频轨道,保持视频不变
ffmpeg -i input.mp4 -an -c:v copy output.mp4

编码器参考

编码器用途编码参数说明
H.264通用用途,最广泛的兼容性-c:v libx264默认选择。到处可用。
H.265存档、流媒体、4K 内容-c:v libx265比 H.264 小约 50%。编码较慢。
VP9网页交付,类似 YouTube 的托管-c:v libvpx-vp9免版税。浏览器支持良好。
AV1下一代网页/流媒体(新兴技术)-c:v libaom-av1最佳压缩率。编码非常慢。
AACMP4 容器中的音频-c:a aac音质好,支持普遍。
Opus语音、音乐、低比特率流媒体-c:a libopus每比特质量最佳。需要 WebM/OGG 容器。
MP3传统音频兼容性-c:a libmp3lame在 AAC/Opus 不被接受时使用。

快速决策指南:

  • 在网页上分享或需要广泛播放?选择 H.264 + AAC 的 MP4。
  • 需要更小的文件且可以等待更久?选择 H.265。
  • 专门面向浏览器?选择 VP9 + Opus 的 WebM。
  • 存档和存储是首要考虑?选择 H.265 或 AV1。

常用参数

-y                  覆盖输出文件而不询问
-n                  从不覆盖输出文件
-hide_banner        隐藏 FFmpeg 构建信息
-v error            仅显示错误(输出更简洁)
-movflags +faststart  将 MP4 元数据移至文件开头(利于流式传输)
-map 0              复制输入中的所有流
-shortest           当最短流结束时停止编码
-threads 0          使用所有可用的 CPU 线程

Individual skills in this repo

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

NeverSight/learn-skills.dev

Use when generating or modifying Remotion video code, creating demo videos, or working with the demo-video/ directory

NeverSight/learn-skills.dev

Create AI avatar and talking head videos via inference.sh CLI. Recommended: P-Video-Avatar (fastest, cheapest, built-in TTS). Also: OmniHuman, Fabric, PixVerse. Audio: Inworld TTS-2 (100+ languages, emotion steering for characters), ElevenLabs, Kokoro. Capabilities: audio-driven avatars, text-to-avatar, lipsync videos, talking head generation, virtual presenters, UGC content. Use for: AI presenters, explainer videos, virtual influencers, dubbing, marketing videos, UGC ads, gaming avatars, NPC dialogue. Triggers: ai avatar, talking head, lipsync, avatar video, virtual presenter, ai spokesperson, audio driven video, heygen alternative, synthesia alternative, talking avatar, lip sync, video avatar, ai presenter, digital human, ugc, ugc video, ugc ad, avatar ugc

NeverSight/learn-skills.dev

Create AI marketing videos for ads, promos, product launches, and brand content. Models: Veo, Seedance, Wan, FLUX for visuals, Kokoro for voiceover. Types: product demos, testimonials, explainers, social ads, brand videos. Use for: Facebook ads, YouTube ads, product launches, brand awareness. Triggers: marketing video, ad video, promo video, commercial, brand video, product video, explainer video, ad creative, video ad, facebook ad video, youtube ad, instagram ad, tiktok ad, promotional video, launch video

NeverSight/learn-skills.dev

Generate AI videos with Google Veo, Seedance 2.0, HappyHorse, Wan, Grok and 40+ models via inference.sh CLI. Models: Veo 3.1, Veo 3, Seedance 2.0, HappyHorse 1.0, Wan 2.5, Grok Imagine Video, OmniHuman, Fabric, HunyuanVideo. Capabilities: text-to-video, image-to-video, reference-to-video, video editing, lipsync, avatar animation, video upscaling, foley sound. Use for: social media videos, marketing content, explainer videos, product demos, AI avatars. Triggers: video generation, ai video, text to video, image to video, veo, animate image, video from image, ai animation, video generator, generate video, t2v, i2v, ai video maker, create video with ai, runway alternative, pika alternative, sora alternative, kling alternative, seedance, happyhorse

NeverSight/learn-skills.dev

ElevenLabs automatic dubbing - translate and dub audio/video into 29 languages while preserving speaker voice via inference.sh CLI. Capabilities: auto speaker detection, voice-preserving translation, video dubbing, audio localization. Use for: content localization, video translation, multilingual content, international distribution. Triggers: dubbing, dub video, translate audio, video translation, audio translation, localize content, elevenlabs dubbing, eleven labs dub, multilingual dub, voice translation, auto dub, language dub, content localization

NeverSight/learn-skills.dev

Explainer video production guide: scripting, voiceover, visuals, and assembly. Covers script formulas, pacing rules, scene planning, and multi-tool pipelines. Use for: product demos, how-it-works videos, onboarding videos, social explainers. Triggers: explainer video, how to make explainer, product video, demo video, video production, video script, animated explainer, product demo video, tutorial video, onboarding video, walkthrough video, video pipeline

NeverSight/learn-skills.dev

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

NeverSight/learn-skills.dev

Generate talking head avatar videos with Pruna P-Video-Avatar via inference.sh CLI. Turn a portrait image into a realistic speaking video with built-in TTS. 18x faster and 6x cheaper than competitors. Models: P-Video-Avatar, P-Image (for portrait generation). Capabilities: text-to-avatar, audio-driven avatars, 30 voices, 10 languages, 720p/1080p, built-in TTS, dynamic backgrounds, full-body control. Use for: AI presenters, product demos, explainer videos, virtual influencers, marketing, education, multilingual content, UGC, gaming avatars. Triggers: avatar video, talking head, ai avatar, p-video-avatar, pruna avatar, video avatar, ai presenter, digital human, virtual presenter, lipsync, talking avatar, ai spokesperson, heygen alternative, synthesia alternative, veed alternative, fabric alternative, omnihuman alternative

NeverSight/learn-skills.dev

Generate videos with Pruna P-Video and WAN models via inference.sh CLI. Models: P-Video, WAN-T2V, WAN-I2V. Capabilities: text-to-video, image-to-video, audio support, 720p/1080p, fast inference. Pruna optimizes models for speed without quality loss. Triggers: pruna video, p-video, pruna ai video, fast video generation, optimized video, wan t2v, wan i2v, economic video generation, cheap video generation, pruna text to video, pruna image to video

NeverSight/learn-skills.dev

Render videos from React/Remotion component code via inference.sh. Pass TSX code, get MP4. Supports all Remotion APIs: useCurrentFrame, useVideoConfig, spring, interpolate, AbsoluteFill, Sequence. Configurable resolution, FPS, duration, codec. Use for: programmatic video generation, animated graphics, motion design, data-driven videos, React animations to video. Triggers: remotion, render video from code, tsx to video, react video, programmatic video, remotion render, code to video, animated video, motion graphics code, react animation video

NeverSight/learn-skills.dev

Video ad creation with exact platform-specific specs for TikTok, Instagram, YouTube, Facebook, LinkedIn. Covers dimensions, duration limits, AIDA framework, and caption requirements. Use for: video ads, social media ads, paid media creative, video marketing, ad production. Triggers: video ad, social media ad, tiktok ad, instagram ad, youtube ad, facebook ad, linkedin ad, video creative, ad specs, paid media, video marketing, ad production, reels ad, stories ad, pre roll, bumper ad

NeverSight/learn-skills.dev

Best practices and techniques for writing effective AI video generation prompts. Covers: Veo, Seedance, Wan, Grok, Kling, Runway, Pika, Sora prompting strategies. Learn: shot types, camera movements, lighting, pacing, style keywords, negative prompts. Use for: improving video quality, getting consistent results, professional video prompts. Triggers: video prompt, how to prompt video, veo prompts, video generation tips, better ai video, video prompt engineering, video prompt guide, video prompt template, ai video tips, video prompt best practices, video prompt examples, cinematography prompts

NeverSight/learn-skills.dev

YouTube thumbnail design with specific dimensions, contrast rules, and mobile preview optimization. Covers safe zones, text placement, face expression psychology, and A/B testing. Use for: YouTube thumbnails, video cover images, click-through optimization. Triggers: youtube thumbnail, thumbnail design, video thumbnail, click through rate, ctr optimization, youtube cover, video cover image, thumbnail maker, thumbnail tips, youtube design, video preview image

NeverSight/learn-skills.dev

Landing page conversion optimization with layout rules, hero section design, and CTA psychology. Covers above-the-fold formula, social proof placement, mobile design, and F-pattern reading. Use for: startup landing pages, product pages, SaaS marketing, conversion optimization. Triggers: landing page, hero section, above the fold, conversion optimization, landing page design, cta button, hero image, landing page layout, saas landing page, product page design, conversion rate, landing page best practices

NeverSight/learn-skills.dev

Configure and use the hosted YouTube Data MCP end-to-end with minimal user input. Use when users want the agent to verify Node.js and `npx`, configure MCP server config (Windows/macOS, Cursor/Codex/OpenClaw/OpenCode), request API key at setup time, run post-install capability discovery (`tools/list` and `get_patch_notes`), and then strongly recommend helper skill and Python setup for full local document and spreadsheet workflows.

NeverSight/learn-skills.dev

Creates 120fps GPU-accelerated animations with Motion.dev (Framer Motion successor) for React, Next.js, Svelte, and Astro projects. Use when user requests animation, motion, scroll effects, parallax, hero animations, gestures, drag interactions, spring physics, whileHover effects, whileInView animations, animated UI, micro-interactions, page transitions, or layout animations. Generates production TypeScript/JSX code with accessibility (prefers-reduced-motion) and performance validation (≥60fps). Supports entrance animations, gesture interactions (hover/tap/drag), scroll-based reveals, and layout transitions using spring physics and natural timing. Do NOT use for CSS-only transitions (use native CSS), static sites without JavaScript, Vue animations (use motion-v variant instead), or SVG/Canvas complex animations (GSAP better suited).

NeverSight/learn-skills.dev

Static artifact craft skill for self-contained HTML/CSS/JS documents: docs, sheets, dashboards, explainers, slides, tools, and landing pages. Use when the user asks for a durable, openable, shareable web deliverable they'll keep or hand off — a report, a dashboard, a slide deck, a data table, a page. Local folder first, temporary public link via tunnel (localhost.run), optional durable publish to Surge, GitHub Pages, or Cloudflare. Not for quick look renders, inline snippets, or throwaway scratch. Not for SPA frameworks, backend APIs, database apps, or production product UI.

NeverSight/learn-skills.dev

Vim keybindings, motions, text objects, and operators for efficient text editing. Use when user asks about "vim commands", "vim motions", "text objects", "vim keybindings", "vim cheat sheet", "learn vim", "vim in VS Code", or any Vim editing tasks.

NeverSight/learn-skills.dev

Download YouTube videos, extract/proofread/translate subtitles, and render them onto video. Use whenever the user asks to download a YouTube video with subtitles, translate video subtitles to Chinese, add subtitles/burn subtitles to a video, or do ASR transcription on video audio. Covers the full pipeline: video download → subtitle extraction → proofreading → translation → SRT generation → subtitle rendering. Also use for "下载视频加字幕", "视频翻译字幕", "把字幕烧录到视频中". For pure subtitle file creation without rendering (just SRT output), this skill handles that too — stop before Phase 5.

NeverSight/learn-skills.dev

Grok Build ONLY. Turn a 2D character still into smooth animation sprites via image_gen/image_edit base → image_to_video (6s/10s run-in-place) → ffmpeg frames → magenta chroma-key → dense sampled sprites (strip/grid/GIF). Use when the user wants video-to-sprite, motion capture from generated video, smoother run/walk cycles from dense frames, or runs /video2dsprite. Do NOT use on Codex/Claude — only Grok Build has image_to_video. Prefer generate2dsprite for crisp pixel sheets without video.

相关技能