{"id":851,"date":"2026-11-28T14:35:52","date_gmt":"2026-11-28T20:35:52","guid":{"rendered":"https:\/\/kop.lat\/blog\/?p=851"},"modified":"2026-11-28T14:44:25","modified_gmt":"2026-11-28T20:44:25","slug":"creating-gifs-on-debian-linux-several-options","status":"publish","type":"post","link":"https:\/\/kop.lat\/blog\/creating-gifs-on-debian-linux-several-options\/","title":{"rendered":"Creating GIFs on Debian Linux &#8211; Options"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1. Install the tools<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install ffmpeg gifsicle imagemagick<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ffmpeg<\/strong> \u2013 best quality + most control<\/li>\n\n\n\n<li><strong>gifsicle<\/strong> \u2013 excellent for optimizing \/ shrinking existing GIFs<\/li>\n\n\n\n<li><strong>ImageMagick<\/strong> \u2013 simple one-liners from images or short clips<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2. High-quality GIF from a video (recommended method)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The best results come from a <strong>two-pass palette<\/strong> approach:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Extract a short clip and generate an optimized palette\nffmpeg -ss 00:00:05 -t 4 -i input.mp4 \\\n  -vf \"fps=12,scale=480:-1:flags=lanczos,palettegen\" palette.png\n\n# Create the GIF using that palette\nffmpeg -ss 00:00:05 -t 4 -i input.mp4 -i palette.png \\\n  -filter_complex \"fps=12,scale=480:-1:flags=lanczos&#91;x];&#91;x]&#91;1:v]paletteuse\" \\\n  output.gif<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Useful options you can change:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Option<\/th><th>Example<\/th><th>Effect<\/th><\/tr><\/thead><tbody><tr><td>Start time<\/td><td><code>-ss 00:01:23<\/code><\/td><td>Seek to that point<\/td><\/tr><tr><td>Duration<\/td><td><code>-t 3<\/code> or <code>-t 00:00:03<\/code><\/td><td>Length of the GIF<\/td><\/tr><tr><td>Frame rate<\/td><td><code>fps=10<\/code> \/ <code>fps=15<\/code> \/ <code>fps=24<\/code><\/td><td>Lower = smaller file<\/td><\/tr><tr><td>Width<\/td><td><code>scale=320:-1<\/code> \/ <code>scale=640:-1<\/code><\/td><td>Height auto-calculated<\/td><\/tr><tr><td>Scaling quality<\/td><td><code>flags=lanczos<\/code><\/td><td>Best quality (recommended)<\/td><\/tr><tr><td>Dithering<\/td><td><code>paletteuse=dither=bayer:bayer_scale=3<\/code><\/td><td>Different dither styles<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">One-liner version of the same thing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -ss 00:00:05 -t 4 -i input.mp4 \\\n  -vf \"fps=12,scale=480:-1:flags=lanczos,split&#91;s0]&#91;s1];&#91;s0]palettegen&#91;p];&#91;s1]&#91;p]paletteuse\" \\\n  output.gif<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3. Quick &amp; simple GIF (lower quality)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -ss 00:00:05 -t 3 -i input.mp4 -vf \"fps=10,scale=400:-1\" output.gif<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4. From a sequence of images<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Numbered images: frame_001.png, frame_002.png \u2026\nffmpeg -framerate 12 -i frame_%03d.png -vf \"scale=480:-1:flags=lanczos\" output.gif\n\n# Or with ImageMagick\nconvert -delay 8 -loop 0 frame_*.png output.gif<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">5. Optimize \/ shrink an existing GIF<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Aggressive optimization\ngifsicle -O3 --lossy=80 input.gif -o optimized.gif\n\n# Resize + optimize\ngifsicle -O3 --resize 320x_ input.gif -o small.gif\n\n# Reduce colors\ngifsicle -O3 --colors 128 input.gif -o reduced.gif<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">6. Other useful variations<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Loop forever (default) or play once:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Already loops by default. To play only once:\nffmpeg ... -loop 1 output.gif   # (actually use -loop 0 for infinite)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Crop a region first:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -i input.mp4 -vf \"crop=640:360:100:50,fps=12,scale=480:-1:flags=lanczos,...\" ...<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Add text overlay:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ffmpeg -i input.mp4 -vf \"drawtext=text='Hello':fontsize=24:fontcolor=white:x=10:y=10,fps=12,...\" ...<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Quick recipe summary<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Goal<\/th><th>Command style<\/th><\/tr><\/thead><tbody><tr><td>Best quality from video<\/td><td>Two-pass palette (fps + scale + palettegen\/use)<\/td><\/tr><tr><td>Fast &amp; simple<\/td><td>Single <code>ffmpeg<\/code> with <code>fps<\/code> + <code>scale<\/code><\/td><\/tr><tr><td>From image sequence<\/td><td><code>ffmpeg -framerate \u2026 -i frame_%03d.png<\/code> or <code>convert<\/code><\/td><\/tr><tr><td>Make file much smaller<\/td><td><code>gifsicle -O3 --lossy=80<\/code><\/td><\/tr><tr><td>Control size<\/td><td>Change <code>scale=WIDTH:-1<\/code> and <code>fps=<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Install the tools 2. High-quality GIF from a video (recommended method) The best results come from a two-pass palette approach: Useful options you can change: Option Example Effect Start time -ss 00:01:23 Seek to that point Duration -t 3 or -t 00:00:03 Length of the GIF Frame rate fps=10 \/ fps=15 \/ fps=24 Lower [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":224,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,4,8],"tags":[5,22],"class_list":["post-851","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-console","category-linux","category-terminal","tag-linux","tag-terminal"],"_links":{"self":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/851","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/comments?post=851"}],"version-history":[{"count":3,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/851\/revisions"}],"predecessor-version":[{"id":854,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/posts\/851\/revisions\/854"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/media\/224"}],"wp:attachment":[{"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/media?parent=851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/categories?post=851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kop.lat\/blog\/wp-json\/wp\/v2\/tags?post=851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}