VideoHelp Forum




+ Reply to Thread
Results 1 to 22 of 22
  1. what is an easy to use to convert very short mp4 videos to gif?
    Quote Quote  
  2. In Virtualdub2

    1 File->Open Video File .. load mp4
    2 [Mark In] and [Mark Out] Specify the 'start' and 'end'
    3 Video->Filters .. if you want apply crop and resize
    4 File->Export->Animated Gif.. (infinity loop)

    Image
    [Attachment 50665 - Click to enlarge]
    責任者-MDX
    Quote Quote  
  3. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    The quality, unfortunately, is not optimal. It seems to build a common 256 color palette over the whole clip. If you have very varying colors, you will notice the quantization. Other tools do a better job here, using partial palette changes, but are not so easy to use (e.g. JASC Animation Shop 3 supports hardly any common video format, not even all VfW codecs in AVI).
    Quote Quote  
  4. This batch file was posted here in the past. It builds a global palette then renders using that palette and error diffusion.

    Code:
    @echo off
    ::** create animated GIF w/ optimized palette
    ::
    :: https://ffmpeg.org/ffmpeg-all.html#gif-2
    :: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
    :: http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality
    
    if not exist "%~dpnx1" goto :EOF
    cd "%~dp1" 
    
    ::** generate palette
    @echo on
    @echo.
    "c:\program files\ffmpeg\bin\ffmpeg.exe" ^
     -v warning -i "%~nx1" ^
     -vf "palettegen" ^
     -y tmp-palette.png
    
    ::** generate GIF
    @echo.
    "c:\program files\ffmpeg\bin\ffmpeg.exe" ^
     -v warning -i "%~nx1" ^
     -i tmp-palette.png ^
     -lavfi "[0][1:v] paletteuse" ^
     "%~n1.gif"
    @echo off
    
    del /q tmp-palette.png
    
    if errorlevel 1 pause
    goto :eof
    Change the path to ffmpeg.exe if necessary. You can then drag/drop any video file onto the batch file to make a GIF.

    A comparison 0f VirtualDub vs ffmpeg using a source with many colors and smooth gradients:

    VirtualDub GIF:
    Image
    [Attachment 50683 - Click to enlarge]


    ffmpeg GIF:
    Image
    [Attachment 50684 - Click to enlarge]
    Quote Quote  
  5. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Wow, that is a clear and noticeable comparison example!

    Scott
    Quote Quote  
  6. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Can I have the original, please? Would like to try the same with Animation Shop 3.
    Quote Quote  
  7. Originally Posted by LigH.de View Post
    Can I have the original, please? Would like to try the same with Animation Shop 3.
    This was made with VirtualDub's Tools -> Create Test Video -> RGB Color Cube. Cropped and decimated.
    Image Attached Files
    Quote Quote  
  8. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Not extremely different to the ffmpeg result. It offers two quantization techniques: Octree and Median cut. But they differ obviously only when there are dominant colors.

    VirtualDub seems to omit error diffusion. I know there are a variety of such algorithms, too, with more or less spread.
    Image Attached Images    
    Quote Quote  
  9. Gif to mp4

    Here a avisynth script with waifu2X(reduction noise and scale), convert any animated video or gif.

    https://youtu.be/kdbhFVZ4vIM
    Last edited by EsteveJohnson; 2nd Nov 2019 at 13:38.
    Quote Quote  
  10. I have a three second mp4 (1.3 mb) I'd like to convert to gif but the free upload converter sites are making the output size huge like 6 and 7 mb?
    Quote Quote  
  11. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Of course. No surprise. Why do you wonder? GIF is not a suitable format for TrueColor sources. It supports at most 256 single distinct colors. To convert 24 bit RGB to 8 bit palette, a selection of the most prominent colors has to be calculated, but every pixel will have a difference to the original color. This error can either be disguised by dithering, then the result will look not too bad, but the compression is low; or it can be ignored, then the result will look ugly but can be compressed a little better. Still, for natural content, modern real video formats like MPEG4 are superior by magnitudes. Animated GIFs will beat MPEG4 video only in case of technical drawings with a low number of distinct colors and sharp edges.
    Quote Quote  
  12. Originally Posted by tom z View Post
    I have a three second mp4 (1.3 mb) I'd like to convert to gif but the free upload converter sites are making the output size huge like 6 and 7 mb?
    It's what LigH said. Also gifs do not use temporal compression in the way modern video formats do, so it's normal for the filesize to get larger


    There are various techniques to optimize gifs in terms of reducing filesize; such as decimating frames (and reducing framerate), variable frame timing, reducing the dimensions, filtering such as denoising, using a farther reduced color pallete, different types of dithering (some make the filesize much larger) . Unlikely that free upload converter sites will do a good job of optimizing it. Some of the decisions require human input on what tradeoffs to be made

    Depending on what the situation is, or if the target site supports it, there might be some alternative formats that are better in terms of quality and filesize, such as animated webp
    Quote Quote  
  13. Member Cornucopia's Avatar
    Join Date
    Oct 2001
    Location
    Deep in the Heart of Texas
    Search PM
    Yup, difference between <1987-era intra-only codec efficiency and >2003-era inter+intra capable codec efficiency.

    Scott
    Quote Quote  
  14. Thanks for the explanation guys!
    Quote Quote  
  15. Originally Posted by jagabo View Post
    This batch file was posted here in the past. It builds a global palette then renders using that palette and error diffusion
    Yea, this works and produce good quality GIF but Camtasia Studio 4 make GIF with there are much fewer pictures. But your script is still better than the VirtualDub > File > Export > Animated GIF... option. VD produce GIF with same number of picture as Camtasia - 69 but some pictures are damaged:
    • your script > 178 pictures 41.8 KB
    • Camtasia Studio 4 > 69 pictures 36.8 KB
    • VirtualDub > 69 pictures 40.5 KB but some pictures damaged

    Total number of frames in my AVI file is 310
    Last edited by jzef; 20th Mar 2026 at 07:21.
    Quote Quote  
  16. Member
    Join Date
    Aug 2013
    Location
    Central Germany
    Search PM
    Another recommendable tool: gifski - github: ImageOptim/gifski (M-AB-S supports building the CLI)
    Quote Quote  
  17. I noticed that the script adds a transparent color and Camtasia does not. I don't know if it's necessary, but I added an option to create the script without a transparent color:
    Code:
     -vf "palettegen=reserve_transparent=0" ^
    How to improve the script so that ffmpeg creates a GIF file with the same number of images as Camatasia or VirtualDub?
    Quote Quote  
  18. If you want fewer frames just change the frame rate to a lower value. ffmpeg will decimate the number of frames to match the specified frame rate and retain the running time.
    Quote Quote  
  19. Member Kakujitsu's Avatar
    Join Date
    Jun 2011
    Location
    United States
    Search Comp PM
    Is there a specific reason you need to use GIF over say Webp, Webm, or APNG? All better formats than GIF with little to no interpolation or artifacting.
    Quote Quote  
  20. Originally Posted by jzef View Post
    How to improve the script so that ffmpeg creates a GIF file with the same number of images as Camatasia or VirtualDub?
    I can't figure out how to set the frame rate directly. But i did find you can use the decimate filter to cut the number of frames in half. Change the line that reads:

    Code:
     -lavfi "[0][1:v] paletteuse" ^
    to:

    Code:
     -lavfi "[0][1:v] paletteuse,decimate=2" ^
    Quote Quote  
  21. Originally Posted by jagabo View Post
    But i did find you can use the decimate filter to cut the number of frames in half. Change the line that reads:
    No, it significantly reduces the quality, but lowering the fps helps
    Code:
     -lavfi "[0][1:v] paletteuse,fps=value" ^
    I tested different fps values ​​and after setting fps=3.37 I obtained the same number of images 69 and a very similar GIF file size 36.3 KB - just like Camtasia Studio 4 does - 69 images 36.8 KB
    Code:
     -lavfi "[0][1:v] paletteuse,fps=3.37" ^
    My tests:

    fps=3.30 > 68 images 36,3 KB
    fps=3.40 > 70 images 36,9 KB

    fps=3.35 > 69 images 37.4 KB
    fps=3.36 > 69 images 37.1 KB

    fps=3.37 > 69 images 36.3 KB

    fps=3.38 > 70 images 36.5 KB
    fps=3.39 > 70 images 36.6 KB


    Thx for cool batch script
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!