Skip to main content
58 events
when toggle format what by license comment
Jul 29, 2023 at 3:11 comment added Geremia This doesn't work with ffmpeg 6.0. I get an error about lanczos deprecated or not found.
S Sep 21, 2022 at 18:56 history suggested K3---rnc CC BY-SA 4.0
Split the nicely documented commands over several lines so the viewer doesn't need to scroll
Sep 21, 2022 at 3:29 review Suggested edits
S Sep 21, 2022 at 18:56
Dec 15, 2021 at 22:59 comment added byxor You're a legend.
Jul 8, 2021 at 8:11 comment added dsvensson @llogan if you measure ffmpeg memory usage on some long 4k hq video with your command line parameters, and then compared that to if you just slice the first second - and in a second invocation perform the gif conversion you should notice reduced memory usage. /usr/bin/time -v is your mem stats friend.
Jun 16, 2021 at 16:34 comment added llogan @VivekThummar Should be asked as a new question.
Jun 16, 2021 at 7:09 comment added Vivek Thummar I don't know if you have ever faced the problem which i faced but let me explain you, in some devices when you pick Camera Video to convert to Gif it will gets stretched because if video is portrait, means orientation is 0 but still it will show 90 or 270, this will only happens to Camera Videos, not to other videos and not on every device(currently in Samsung, OnePlus works fine but not on Realme).
Dec 24, 2020 at 18:45 comment added llogan @mayank1513 Your ffmpeg must be really old, or you have configured it to remove support for this filter.
Dec 24, 2020 at 8:30 comment added Mayank Kumar Chaudhari It is giving No such filter: 'palettegen' Error opening filters! error
Nov 19, 2020 at 18:16 comment added llogan @dsvensson Never noticed a memory issue (but I'm not making GIFs often and they are using inputs only seconds long). How can the issue be duplicated? What are your commands to resolve it? You can use a pastebin link. Thanks.
Nov 19, 2020 at 8:08 comment added dsvensson @llogan I found your snippet in a code base recently when trouble shooting why ffmpeg used so much memory, and takes so much time. Turns out that by slicing out the duration beforehand to a temporary file with the same container as input (null audio video copy), and then doing the fps/scale/palette/gif uses a fraction of the memory in a fraction of the time. No idea why, one guess is that palette operates on the whole video otherwise, not sure.
Oct 19, 2020 at 21:17 comment added Atralb @llogan My bad, VLC was the culprit. I didn't know it couldn't read gifs. I'll delete the comments
Sep 13, 2020 at 22:25 comment added ijoseph Source for why lanczos is a good choice here. TLDR good for both downsampling and upsampling.
May 5, 2020 at 18:12 comment added Edward Falk Wow; thank you. My animated gifs are now incredibly improved.
Apr 15, 2020 at 18:53 comment added llogan @Farshan GIF is an antiquated format, so size will always be relatively high. Use a lower fps, smaller scale, and/or shorter -t. You can also reduce the number of colors as in palettegen=max_colors=64.
Apr 15, 2020 at 18:36 comment added Farshan I tried creating a GIF of 3 seconds from a 990 KB video of resolution 640 * 360 having a duration of 14 seconds. But the output GIF is having a size of 1.17 MB. I'm using ffmpeg command. ffmpeg -t 3 -i inputfile.mp4 -vf ""fps = 10,scale = 320:-1:flags = lanczos,split[s0][s1];[s0] palettegen[p];[s1] [p] paletteuse"" -loop 0 outputfile.gif. Is there any way to reduce the size without using ImageMagick?
Feb 5, 2020 at 1:14 history edited llogan CC BY-SA 4.0
beyer/bayer typo
Feb 5, 2020 at 0:57 history edited llogan CC BY-SA 4.0
mentioned stats_mode and dither options. added conver options. other minor changes.
Dec 16, 2019 at 21:42 history edited llogan CC BY-SA 4.0
added 191 characters in body
Dec 16, 2019 at 21:34 comment added llogan @VitalyZdanevich Answer updated.
Dec 16, 2019 at 21:34 history edited llogan CC BY-SA 4.0
added more info as requested
Dec 16, 2019 at 21:02 comment added Vitaly Zdanevich Please describe all options, what is -c:v pam?
Jul 31, 2019 at 1:10 history edited llogan CC BY-SA 4.0
updated old answer. switched to public domain video.
Jul 27, 2019 at 10:22 comment added Leonid Usov For the ffmpeg-only solution, I encourage the use of this brilliant single call with filter graph solution from @alijandro
Jan 30, 2019 at 22:25 comment added llogan @user1308990 [x] is just the label of the output coming from the fps=10,scale=320:-1:flags=lanczos filterchain. The label is then referred to by other, separate filterchains or the output file. The label can be almost any arbitrary name, so you could rename it to whatever makes most sense to you. See FFmpeg Filtering: Introduction for more info.
Jan 29, 2019 at 13:39 comment added user1308990 What is [x] ?? Why nobody on the whole earh mentioned this [x]?
Oct 7, 2018 at 8:15 comment added Coder Guy This Q&A must be permanently encoded in a tome (or maybe just "pinned" for now) because in a hundred years from now all communication will be done via memes. I think the activity on this post alone speaks to that.
Jul 21, 2018 at 21:17 comment added llogan @MikhailT. The full scale part is scale=320:-1:flags=lanczos. The flags is an option for scale. I probably should not have included that in the example as it increased complexity of the example.
Jul 21, 2018 at 19:41 comment added Mikhail T. Err, never mind. I tried removing the scale=360 part and that didn't work. Don't know, why...
Jul 21, 2018 at 19:32 comment added llogan @MikhailT. Works for me. Please show your actual command and the complete log. You can use a pastebin site and provide the link here.
Jul 21, 2018 at 19:01 comment added Mikhail T. Trying the very first command - to generate the pallette (with ffmpeg-4.0.1): Option 'flags' not found. ffmpeg would've been a lot more useful, if the developers knew the concept of backwards compatibility...
Jul 18, 2018 at 17:20 comment added llogan @ChrisSteinbeckBell Might be worth asking this as a new question and I or someone else can help. Comments may be too limited.
Jul 18, 2018 at 2:04 comment added Chris Steinbeck Bell @LordNeckbeard just after the input but I can't make ffmpeg to interpret the command the way I need, perhaps can you help me with that?. I'd be really grateful.
Jul 18, 2018 at 2:04 comment added Chris Steinbeck Bell @LordNeckbeard Thanks for replying back, but I'd appreciate you could help me with the part of the code regarding time as I'm not too saavy enough to do that modification by myself. As I mentioned I tried to use seek command as ffmpeg documentation suggests the way of -ss 00:24:25 to 00:25:52
Jul 17, 2018 at 19:38 comment added llogan @ChrisSteinbeckBell I chose a value low enough to make the GIF smaller in file size, but high enough to look acceptable. You'll just have to experiment depending on your content.
Jul 16, 2018 at 8:25 comment added Chris Steinbeck Bell @LordNeckbeard Also the framerate you use how did you obtained?. Does it come from the input movie or is it just a random value that you chosen?
Jul 16, 2018 at 8:25 comment added Chris Steinbeck Bell @LordNeckbeard How to can I modify your code to take let's say from a particular interval of a movie of let's say between 00:24:45 to 00:25:52? I tried to use the seek command and it did not work!. Can you perhaps help me with this?. I would like to know how to make it work with the palette you say to make and use ffmpeg to build up from that the gif. Btw I used the code as you mention and it works but to take a sample from longer intervals such as I mentioned is not very practical as I have to translate the minutes or hours to seconds.
Apr 30, 2018 at 9:54 comment added Marcus Mangelsdorf Giphy Engineering has released a nice article recently explaining all the options: engineering.giphy.com/how-to-make-gifs-with-ffmpeg
Sep 16, 2017 at 12:20 comment added Mousa Alfhaily Okay, I've got it, i used scale=0:-1, so when you set the scale to 0, it will take the scale from the video.
Sep 16, 2017 at 12:07 comment added Mousa Alfhaily How if i don't want to set the scale, i need to make him the the video's scale automatically?
Sep 20, 2016 at 16:22 comment added Jordan Your ffmpeg example has become a common enough workflow for me that I wrote a bash wrapper script to automate it. Sharing here: github.com/jordanh/ffmpeg2gif
Jun 2, 2016 at 9:35 comment added Gergely Lukacsy In the second approach, you can use ffmpeg instead of imagick. All you need to do, is to use the image2 demuxer's framrate option, so you can set the delay between individual frames: ffmpeg -framerate -i frames/ffout*.png output.gif
May 29, 2016 at 4:23 comment added user38537 Bravo! I used the "ffmpeg example" to convert a CamStudio recording of my screen showing a RAID5 parity recovery of a flash drive RAID5 array. The recovery took about an hour. During that time, I teed the output to a text file. The video was actually the recording of my parsing the text. the AVI was 1.4 GB; the GIF was 2.5 MB.
May 15, 2016 at 21:40 comment added Bruno Augusto Is it it possible to crop a few pixels from the resulting GIF? I love these funny GIF from real movies/cartoons scenes, but I've found one, with a bad quality, in which the top... 5cm, more or less, is damaged. If I need to open a new thread I'll gladly
Feb 2, 2016 at 18:13 history edited llogan CC BY-SA 3.0
deverbosify edit
S Feb 2, 2016 at 18:07 history suggested TheDrPfeffer CC BY-SA 3.0
Updated command line for use with graphics magick
Feb 2, 2016 at 17:46 review Suggested edits
S Feb 2, 2016 at 18:07
Apr 28, 2015 at 22:17 history edited llogan CC BY-SA 3.0
mention new GIF encoding features
Sep 27, 2014 at 0:16 comment added Jack O'Connor I think the convert command should be using -delay 10 (0.1 seconds between frames) to match the -r 10 (10 fps) frame rate you're feeding to ffmpeg. When I use -delay 5, I see the gif play at double speed.
Jul 24, 2014 at 13:58 comment added Wilf By the way, for the convert command for converting from the PNG frames I ended up using convert -delay 5 -loop 0 -dither None -colors 80 "frames/ffout*.png" -fuzz "40%" -layers OptimizeFrame "output.gif", which reduces the overall file size quite a bit
Jul 5, 2014 at 23:00 comment added Wilf @LordNeckbeard - the convert option worked brilliantly - also using an ancient version of ffmpeg directly got a file size of 300Mb with rubbish output, whilst the high quality one from convert was 13Mb...
Oct 29, 2013 at 21:37 history edited slhck CC BY-SA 3.0
update for newer ffmpeg versions (better default quality, yay)
Sep 4, 2013 at 20:00 history edited llogan CC BY-SA 3.0
note about `format=rgb8,format=rgb24`
Feb 22, 2013 at 22:25 history migrated from stackoverflow.com (revisions)
Feb 22, 2013 at 21:53 vote accept Kamil Hismatullin
Feb 22, 2013 at 21:53 comment added Kamil Hismatullin @LordNeckbeard, you are awesome! much thanks for -vf scale=320:-1,format=rgb8,format=rgb24
Feb 22, 2013 at 21:44 comment added slhck Added some example results (just still frames though). Here, the first file is 4.1 MB, the second around 8 MB.
Feb 22, 2013 at 21:31 history answered llogan CC BY-SA 3.0