How Do I Use Ffmpeg To Create The Highest Quality Animated Gifs From Video Clips?

Discussion in 'Software' started by Jesse Newell, May 10, 2019.

  1. Jesse Newell

    Jesse Newell MajorGeek

    I'm hoping for minimal colour loss (I often find in gifs I create with ffmpeg that women with red/pinkish lipstick often have the colour in their lips washed out to a golden brown!), minimal banding (preferably none), minimal noise, and NO crosshatch patterning. I normally just use this standard command,

    Code:
    ffmpeg -i input.ext -vf palettegen palette.png
    followed by

    Code:
    ffmpeg -i input.ext -i palette.png -lavfi paletteuse output.gif
    and they work pretty fine most of the time. But then there are these clips where, as I've said, I often notice women's lips being drained of colour. Instead of a healthy crimson, they often look yellowy/browny/goldy/beigey/orangey. Can someone help me out?
     
  2. Jesse Newell

    Jesse Newell MajorGeek

    PS In case anyone wants to tell me the golden lips are a result of the limitations of the gif format, there's a program called Instagiffer that can make gifs of the same videos without that colour loss. The women keep their red lips. Only reasons I don't choose to use that over ffmpeg are it's incredibly slow and ya have to "enhance" each gif to eliminate banding. I just want gifs as close as I can get to the original videos. Better isn't necessary.
     
  3. Eldon

    Eldon Major Geek Extraordinaire

    Really?
    How do you explain this when the GIF format is limited to 8-bit and 256 colours?
     
  4. Jesse Newell

    Jesse Newell MajorGeek

    Beats me. All I know is, I make a gif of a video of a woman with red lipstick using ffmpeg and her lips come out golden brown. I make a gif of the same video with Instagiffer and her lips come out just as red as in the original video. But, like I said, with Instagiffer, I have to enhance the gif to eliminate banding. Getting rid of banding is fine but it makes the gif look a lot sharper than I want it to. And Instagiffer is very very very slow.
     
  5. Jesse Newell

    Jesse Newell MajorGeek

    Found the solution. This works on my Windows 8.1 system anyway. Might need ImageMagick which I installed yesterday. Don't know if it's necessary for this. Install Instagiffer (which ya won't actually need so ya can uninstall it later), search with Everything for an executable called convert.exe which ya should find in one of the Instagiffer folders, copy it to the folder ya plan on calling ffmpeg in, then uninstall Instagiffer. Copy the video ya wanna convert to a gif to the same folder, then open a command prompt, change directory to the folder, and paste in this code, substituting in the correct values for the bits in red,

    ffmpeg -i videoname.ext -vf scale=width:height -r fps -f image2pipe -vcodec ppm - | convert - delay 1xnumber - gif:- | convert -layers Optimize -loop 0 - gifname.gif
     
  6. Jesse Newell

    Jesse Newell MajorGeek

    Made a slight typo with that code. This is the correct version,

    ffmpeg -i videoname.ext -vf scale=width:height -r fps -f image2pipe -vcodec ppm - | convert -delay 1xnumber - gif:- | convert -layers Optimize -loop 0 - gifname.gif
     
  7. Jesse Newell

    Jesse Newell MajorGeek

    Another much simpler way is to just use VirtualDub2 to scale a video down to a more reasonable size, save it as a new video, close the file, then click Tools, Create palettized AVI, select the new video ya just made, and save the palettized AVI (videoname.avi) in the folder you're gonna call ffmpeg in, then open a command prompt in that folder and paste in this code,

    ffmpeg -i videoname.avi videoname.gif

    The result won't be as nice. A bluish tint and quite some noise but the file size will be a LOT smaller than the previous method produces.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds