VideoHelp Forum
+ Reply to Thread
Results 1 to 15 of 15
Thread
  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  



Similar Threads

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