惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Palo Alto Networks Blog
AWS News Blog
AWS News Blog
Latest news
Latest news
Microsoft Security Blog
Microsoft Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
大猫的无限游戏
大猫的无限游戏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
C
CERT Recently Published Vulnerability Notes
T
Tenable Blog
雷峰网
雷峰网
K
Kaspersky official blog
人人都是产品经理
人人都是产品经理
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
T
The Exploit Database - CXSecurity.com
T
Tor Project blog
A
Arctic Wolf
Project Zero
Project Zero
F
Fortinet All Blogs
T
Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
P
Privacy & Cybersecurity Law Blog
D
DataBreaches.Net
量子位
Cisco Talos Blog
Cisco Talos Blog
博客园 - 【当耐特】
V
Visual Studio Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 叶小钗
I
Intezer
G
GRAHAM CLULEY
Google Online Security Blog
Google Online Security Blog
T
The Blog of Author Tim Ferriss
T
Troy Hunt's Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News: Ask HN
Hacker News: Ask HN
M
MIT News - Artificial intelligence
N
News | PayPal Newsroom
Cyberwarzone
Cyberwarzone
V
V2EX
腾讯CDC
Webroot Blog
Webroot Blog
MongoDB | Blog
MongoDB | Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
How to Convert MP4 to GIF with FFmpeg (High Quality, Small File)
Javid Jamae · 2026-05-01 · via DEV Community
<p><em>Originally published at <a href="https://www.ffmpeg-micro.com/blog/convert-mp4-to-gif-ffmpeg" rel="noopener noreferrer">ffmpeg-micro.com</a>.</em></p> <p>Converting an MP4 to a GIF with FFmpeg sounds simple until you actually try it. The default output is either a blurry mess or a 50MB file that nobody wants to load. The trick is knowing which FFmpeg flags control quality and file size independently.</p> <h2> The Basic Command (and Why It Looks Bad) </h2> <p>The most basic FFmpeg conversion looks like this:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>ffmpeg <span class="nt">-i</span> input.mp4 output.gif </code></pre> </div> <p>This technically works. But the result will look terrible.</p> <p>GIFs are limited to 256 colors per frame. FFmpeg's default color selection doesn't pick the right 256 to keep, so you get banding, dithering artifacts, and washed-out colors. The file will also be massive because there's no compression optimization happening. A 10-second 1080p clip can easily produce a 100MB+ GIF.</p> <h2> High-Quality GIFs with Palette Generation </h2> <p>The fix is FFmpeg's <code>palettegen</code> and <code>paletteuse</code> filters. This two-pass approach first analyzes your video to build an optimal 256-color palette, then converts using that palette instead of guessing.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code><span class="c"># Pass 1: Generate the optimal color palette</span> ffmpeg <span class="nt">-i</span> input.mp4 <span class="nt">-vf</span> <span class="s2">"fps=10,scale=480:-1:flags=lanczos,palettegen"</span> palette.png <span class="c"># Pass 2: Convert using that palette</span> ffmpeg <span class="nt">-i</span> input.mp4 <span class="nt">-i</span> palette.png <span class="nt">-filter_complex</span> <span class="s2">"fps=10,scale=480:-1:flags=lanczos[x];[x][1:v]paletteuse"</span> output.gif </code></pre> </div> <p>The difference is dramatic. Colors stay vibrant, gradients are smooth, and dithering artifacts mostly disappear.</p> <p>What each flag does:</p> <ul> <li> <code>fps=10</code> reduces the frame rate from the source (usually 24-30fps) to 10fps, cutting file size significantly</li> <li> <code>scale=480:-1</code> resizes to 480px wide while maintaining aspect ratio</li> <li> <code>flags=lanczos</code> uses Lanczos resampling for sharper downscaling</li> <li> <code>palettegen</code> analyzes all frames and builds the best 256-color palette</li> <li> <code>paletteuse</code> applies that palette during conversion</li> </ul> <p>You can also do this in a single command using <code>split</code> to avoid the intermediate palette file:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>ffmpeg <span class="nt">-i</span> input.mp4 <span class="nt">-filter_complex</span> <span class="s2">"[0:v] fps=10,scale=480:-1:flags=lanczos,split [a][b];[a] palettegen [p];[b][p] paletteuse"</span> output.gif </code></pre> </div> <p>Same quality, one command, no temp files.</p> <h2> Controlling File Size </h2> <p>GIF files get big fast. Three things control the size: duration, resolution, and frame rate.</p> <p><strong>Trim to a specific clip</strong> with <code>-ss</code> (start time) and <code>-t</code> (duration):<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>ffmpeg <span class="nt">-ss</span> 00:00:05 <span class="nt">-t</span> 3 <span class="nt">-i</span> input.mp4 <span class="nt">-filter_complex</span> <span class="s2">"[0:v] fps=10,scale=320:-1:flags=lanczos,split [a][b];[a] palettegen [p];[b][p] paletteuse"</span> output.gif </code></pre> </div> <p>This extracts 3 seconds starting at the 5-second mark.</p> <p><strong>Sizing reference:</strong></p> <div class="table-wrapper-paragraph"><table> <thead> <tr> <th>Resolution</th> <th>FPS</th> <th>5s clip</th> <th>10s clip</th> </tr> </thead> <tbody> <tr> <td>320px wide</td> <td>10</td> <td>~1-3MB</td> <td>~2-6MB</td> </tr> <tr> <td>480px wide</td> <td>10</td> <td>~3-6MB</td> <td>~5-12MB</td> </tr> <tr> <td>640px wide</td> <td>15</td> <td>~8-15MB</td> <td>~15-30MB</td> </tr> <tr> <td>1080px wide</td> <td>24</td> <td>~30-80MB</td> <td>~60-150MB</td> </tr> </tbody> </table></div> <p>For web use, 480px wide at 10fps is the sweet spot. Anything over 640px is usually overkill for a GIF.</p> <h2> Loop Control </h2> <p>GIFs loop forever by default. Control this with the <code>-loop</code> output option:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code><span class="c"># Play 3 times then stop</span> ffmpeg <span class="nt">-i</span> input.mp4 <span class="nt">-filter_complex</span> <span class="s2">"[0:v] fps=10,scale=480:-1:flags=lanczos,split [a][b];[a] palettegen [p];[b][p] paletteuse"</span> <span class="nt">-loop</span> 3 output.gif <span class="c"># Play once, no loop</span> ffmpeg <span class="nt">-i</span> input.mp4 <span class="nt">-filter_complex</span> <span class="s2">"[0:v] fps=10,scale=480:-1:flags=lanczos,split [a][b];[a] palettegen [p];[b][p] paletteuse"</span> <span class="nt">-loop</span> <span class="nt">-1</span> output.gif </code></pre> </div> <p><code>-loop 0</code> is infinite (the default). <code>-loop -1</code> plays once. <code>-loop N</code> plays N+1 times total.</p> <h2> Common Pitfalls </h2> <p><strong>The 256-color limit hits hardest on gradients and transitions.</strong> If your video has rapid color changes between scenes, you'll see color flickering. Adding <code>dither=bayer:bayer_scale=5</code> to the <code>paletteuse</code> filter smooths this out: <code>paletteuse=dither=bayer:bayer_scale=5</code>.</p> <p><strong>GIF transparency is binary.</strong> No semi-transparent pixels. If you're converting video with an alpha channel, expect hard edges instead of smooth blending.</p> <p><strong>Audio gets silently dropped.</strong> GIFs don't support audio and FFmpeg won't warn you about it. If you need sound, stick with MP4 or WebM.</p> <p><strong>Skipping palette generation is the single biggest mistake.</strong> The quality difference between a naive conversion and the palette method is night and day. Always use <code>palettegen</code> + <code>paletteuse</code> unless file size truly doesn't matter.</p> <h2> Convert MP4 to GIF with an API </h2> <p>If you'd rather skip the FFmpeg installation and two-pass workflow, FFmpeg Micro converts videos to GIF with a single API call:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>curl <span class="nt">-X</span> POST https://api.ffmpeg-micro.com/v1/transcodes <span class="se">\</span> <span class="nt">-H</span> <span class="s2">"Authorization: Bearer YOUR_API_KEY"</span> <span class="se">\</span> <span class="nt">-H</span> <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span> <span class="nt">-d</span> <span class="s1">'{ "inputs": [{"url": "https://example.com/video.mp4"}], "outputFormat": "gif", "options": [ {"option": "-vf", "argument": "fps=10,scale=480:-1:flags=lanczos"} ] }'</span> </code></pre> </div> <p>You get back a job ID, poll for completion, and download the result. No infrastructure to manage, no FFmpeg to install, no server resources to worry about when processing volume spikes.</p> <p>Trim the source video before conversion with input-level options:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>curl <span class="nt">-X</span> POST https://api.ffmpeg-micro.com/v1/transcodes <span class="se">\</span> <span class="nt">-H</span> <span class="s2">"Authorization: Bearer YOUR_API_KEY"</span> <span class="se">\</span> <span class="nt">-H</span> <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span> <span class="nt">-d</span> <span class="s1">'{ "inputs": [{ "url": "https://example.com/video.mp4", "options": [ {"option": "-ss", "argument": "5"}, {"option": "-t", "argument": "3"} ] }], "outputFormat": "gif", "options": [ {"option": "-vf", "argument": "fps=10,scale=480:-1:flags=lanczos"} ] }'</span> </code></pre> </div> <p>FFmpeg Micro handles the infrastructure and auto-scales with your workload. Pay per minute of video processed, with a free tier to start. <a href="https://www.ffmpeg-micro.com/pricing" rel="noopener noreferrer">Create your free account to get an API key</a>.</p> <p>For a deeper dive on FFmpeg encoding fundamentals, check out the <a href="https://dev.to/training/learn-ffmpeg">Learn FFmpeg course</a>.</p> <h2> Frequently Asked Questions </h2> <h3> What's the best resolution for a web GIF? </h3> <p>480px wide at 10fps works for most use cases. Short clips stay under 5MB, which loads quickly on any connection. Drop to 320px if the GIF is for chat or messaging apps where bandwidth matters more than detail.</p> <h3> Why does my FFmpeg GIF look grainy or washed out? </h3> <p>You're probably running <code>ffmpeg -i input.mp4 output.gif</code> without palette generation. FFmpeg's default color quantization produces poor results with only 256 colors to work with. The two-pass <code>palettegen</code> and <code>paletteuse</code> method described above fixes this completely.</p> <h3> Can I convert a GIF back to MP4 with FFmpeg? </h3> <p>Yes. Run <code>ffmpeg -i input.gif -movflags faststart -pix_fmt yuv420p output.mp4</code>. The MP4 will be much smaller because H.264 compression is far more efficient than GIF's LZW compression. Platforms like Twitter and Imgur convert uploaded GIFs to MP4 behind the scenes for this exact reason.</p> <h3> Is animated WebP better than GIF? </h3> <p>For most cases, yes. Animated WebP supports 24-bit color (16.7 million colors vs GIF's 256), produces smaller files at equivalent quality, and handles transparency with proper alpha blending. GIF's advantage is universal compatibility: it works in email clients, legacy browsers, and systems where WebP isn't supported.</p> <h3> How do I make a GIF from just part of a video? </h3> <p>Use <code>-ss</code> for the start time and <code>-t</code> for duration before the input: <code>ffmpeg -ss 00:00:30 -t 5 -i input.mp4 output.gif</code>. This grabs 5 seconds starting at the 30-second mark. Combine it with the palette method for the best quality.</p>