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,
followed byCode:ffmpeg -i input.ext -vf palettegen palette.png
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?Code:ffmpeg -i input.ext -i palette.png -lavfi paletteuse output.gif
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.
+ Reply to Thread
Results 1 to 14 of 14
-
-
The problem is that gif uses a 256 color palette. Some programs choose the colors based one what colors appear most in the video. If reds are a very small portion of the video reds will not be in the 256 colors palette. So you need to generate a palette that includes red for the lips.
One way of doing that is to use a palette that has 256 colors spread throughout the RGB cube. The problem with that is you may end up with banding or a very grainy image.
Another way is to trick ffmpeg into generating a palette with reds. Maybe by cropping the video to a smaller area when generating the palette. But then you may miss colors in other parts of the frame. -
-
In GIF every frame may have own 256CLUT (it will increase size of frame by 768 bytes), using proper dithering may save bandwidth.
Script provided bellow may be helpful, feel free to modify:
Code:@echo off @setlocal @set /p CLUT=How Many Colors (4..256): @echo Number of colors: %CLUT% @set /p BS=Bayer_Strength (0..5 lower is stronger): @echo Bayer Strength: %BS% @echo Generating Palette... @ffmpeg.exe -i %1 -vf "palettegen=max_colors=%CLUT%:reserve_transparent=0:stats_mode=diff" %1_C%CLUT%_D.png @echo Generating GIF... @rem echo --video-- @rem possible vidither are: 0,1,2,3,4,5,6 or "bayer","ed","a_dither", "x_dither" @set vidither=a_dither @ffmpeg.exe -i %1 -i %1_C%CLUT%_D.png -lavfi "paletteuse=dither=bayer:bayer_scale=%BS%" -sws_dither %vidither% -loop 0 -vsync 0 %1_C%CLUT%_BS%BS%.gif @ffmpeg.exe -i %1 -i %1_C%CLUT%_D.png -lavfi "paletteuse=dither=sierra2_4a" -sws_dither %vidither% -loop 0 -vsync 0 %1_C%CLUT%_S.gif @echo Optimizing GIF... @rem gifsicle.exe -V -O2 %1_d.gif -o %1_d_o.gif @rem gifsicle.exe -V -O2 %1_d_b2.gif -o %1_d_b2_o.gif @rem gifsicle.exe -V -O2 %1_f.gif -o %1_o_f.gif @echo DONE^^! Press ENTER to close window... @PAUSE
Bellow link may be useful too:
https://medium.com/@colten_jackson/doing-the-gif-thing-on-debian-82b9760a8483
http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
http://pippin.gimp.org/a_dither/
https://forum.videohelp.com/threads/365696-avi-to-Gif-%28High-quality%29
You may think about creating single CLUT using tircks that works for me OK (sometimes) - i generate large pic made from series of video frames and i use modern color quantization algorithm such as https://scientificgems.wordpress.com/stuff/neuquant-fast-high-quality-image-quantization/ or https://people.eecs.berkeley.edu/~dcoetzee/downloads/scolorq/ - both deliver very good perceived quality. -
How long are your GIF's? If they are not too long you can use FFMPEG and a free software called CONVERT.EXE which is part of ImageMagick. Below is a sample video and the subsequent optimized and non-optimized GIF's. I ask abouty length because Convert is memory intensive and long conversions will tie up your CMD process for quite a while as well as use a lot of memory. Small videos are no problem and usually come out pretty well.
[Attachment 49036 - Click to enlarge]
Code:ffmpeg -i "C:\Users\Bud\Desktop\250_red.mp4" -vf scale=640:480 -r 20 -f image2pipe -vcodec ppm - | convert -delay 5 - gif:- | convert -layers Optimize -loop 0 - "C:\Users\Bud\Desktop\250_red_Gif_1.gif"
[Attachment 49037 - Click to enlarge]
Code:ffmpeg -i "C:\Users\Bud\Desktop\250_red.mp4" -vf scale=640:480 -r 20 -f image2pipe -vcodec ppm - | convert -delay 5 -loop 0 - "C:\Users\Bud\Desktop\250_red_Gif_1.gif"
[Attachment 49038 - Click to enlarge] -
Sorry, mate, I appreciate the help but I'm not tech-minded. I don't understand any of that, sorry. But one of those links proved useful. I learned how to create a palettized avi with virtualdub, so that helped. Thanks. The resulting gifs do have more noise than I'd like but I guess that's the price of colour retention.
-
Hi. Just tried the first command. I'll let ya know how it goes. It's taking a lot longer than I thought it would. What does "-delay 5" mean?
EDIT: Holy shit, that worked brilliantly! Thanks! That does exactly what I was hoping for. Only slight problem was the gif seemed a bit slow. I think that must be the "-delay 5" bit so I took it out and am trying again now.
EDIT: Oops, taking out the "-delay 5" bit made it slower. How do I fix that? The video's fps is 24.601. I put that in for -r. What do I need to do to get the gif to play at the same fps?Last edited by Bruce Banner; 10th May 2019 at 16:37.
-
The -r and -delay work together with computing animation speed. I use a program that plugs it in automatically . I will post that and an explaination later when I get my computer fired up. For now changing one or bother affect the outcome in different ways. How exactly fails my memory at this minute,but I will post later.
Try this web page for now for an explanation.
https://imagemagick.org/script/convert.phpLast edited by Budman1; 10th May 2019 at 17:00.
-
From https://imagemagick.org/Usage/anim_basics/
-delay {time} Set the time delay (in 1/100th of a second) to pause after drawing the images that are read in or created after this setting has been defined.
You can specify a different scale for the time delay by specifying a 'x' scaling (giving in ticks per second). For example '10x1' is 10, 1 second ticks, while '10x100' is 10, one hundredth of a second ticks.
Basically the 'x' is equivalent to a fraction '/' sign. For example if you specify '1x160' will set a delay that is appropriate for 160 frames per second.
GIF animation delays must be specified in hundredths of a second for correct working, which is why that is the default time unit. The 'x' factor is used more for generating other more movie like formats, such a MNG's, and AVI's. -
FYI... Anyone interested in the use of ImageMagick's Convert, I have enclosed several images and an explanation of the use of '-delay" and '-r'.
Using a 30 FPS MP4, Calibrated in microseconds, I used the delay of 5 and FPS of 20 and time of 10 (-t 10).
This is calibrated as:
FPS x Time = Frames (20 x 10 = 200 Frames)
Frames / Time = Frames per second of GIF (200 / 10 = 20 FPS of GIF)
Ticks per second / GIF FPS = delay ( 100 / 20 = delay of 5)
Notice in the image below the final GIF has approximately 200 Frames in 10 seconds compared to the MP4 that has 300 (30 x 10) . This is proportional to Gif FPS / Source FPS, even though the video will run for the approximate time specified (10 seconds).
OOPS. The second image should show input as MP4 not GIF.
[Attachment 49039 - Click to enlarge]
[Attachment 49040 - Click to enlarge]
[Attachment 49041 - Click to enlarge]
Similar Threads
-
Highest Quality Video Editing
By lomaidala in forum EditingReplies: 70Last Post: 25th Jul 2023, 17:55 -
Easiest good video software to create animated video?
By mikehende in forum Newbie / General discussionsReplies: 4Last Post: 2nd Jun 2022, 05:53 -
Batch convert animated GIFs to video? (Any format: AVI, MP4, etc.)
By vidyanoob in forum Video ConversionReplies: 3Last Post: 31st May 2018, 09:04 -
Combine JPGs and animated GIFs to video? (Any format ok. MP4, MKV, etc.)
By vidyanoob in forum Video ConversionReplies: 6Last Post: 31st May 2018, 03:09 -
Why Is Chrome So Bad At Handling Animated Gifs?
By Bruce Wayne in forum ComputerReplies: 17Last Post: 12th Apr 2016, 02:50