Communitygithub.com

NeverSight/learn-skills.dev

FFmpeg 指令集,用於影片/音訊轉換、修剪、壓縮和處理。當使用者提到「ffmpeg」、「轉換影片」、「壓縮影片」、「擷取音訊」、「修剪影片」、「影片轉 GIF」、「影片編解碼器」、「轉碼」、「螢幕錄製」、「合併影片」、「影片轉 MP4」、「減少檔案大小」或任何媒體處理任務時使用。

learn-skills.dev 是什麼?

此技能提供了一份全面的 FFmpeg 與 FFprobe 指令參考清單,涵蓋媒體處理中最常見的操作,包括格式轉換、影片壓縮(CRF 模式、固定檔案大小)、音訊擷取與轉換、精準修剪與裁切、GIF 製作、縮放與尺寸調整、字幕處理(硬編碼與軟字幕)、影片合併與串接、畫面擷取、螢幕錄製(macOS、Linux X11)、速度調整以及音訊移除。每個指令都附有詳細的註解,說明參數的作用與使用情境,並在最後提供編解碼器選擇指南與常用旗標速查表。這個技能適用於任何支援 FFmpeg 命令列工具的 AI 代理平台(如 Claude Code、Cursor、Codex),能顯著提升開發者與內容創作者處理媒體檔案的效率。用戶只需以自然語言描述需求,此技能即可映射到對應的 FFmpeg 指令,省去記憶繁雜參數的麻煩。

相容平台~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 或搭配 PipeWire 的 OBS。

加速與慢速播放

# 影片加速 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.

相關技能