VideoHelp Forum




+ Reply to Thread
Results 1 to 8 of 8
  1. Member
    Join Date
    May 2016
    Location
    Munich
    Search PM
    Hello all,

    i scanned the whole web (including this site of course) to answer tis question myself but finally failed:

    I need a tool to batch-convert MPGs to animated GIFs. Only thing, which Needs to be done in addition to the conversion is, to delete the first of 24 Frames.

    Unfortunately the software, which outputs the MPGs (vibration-loops of a CAE-Simulation) always puts an annoying extra frame in first position, which makes the loops bump.

    As i have to convert a lot of these MPGs every week, it would be really nice to get it done by script or batch. I found several solutions to do it manually file by file, like VitualDub, but none of them really batchable.

    I was hoping, that maybe VirtualSynth could be the one, but didnīt find a way to export GIF.

    Would be very great, if anyone of you had a good hint, how it yould be done.

    Thx in advance, Markus
    Quote Quote  
  2. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    virtualsynth??

    Have you googled for ffmpeg examples?

    http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-wit...onable-quality

    And try use -ss to seek 1 second. https://trac.ffmpeg.org/wiki/Seeking

    After you get a working ffmpeg command can you make a batch file for that.
    Quote Quote  
  3. In ffmpeg, you can also use -vf_trim=start_frame=24 . Frame numbering starts at "zero" in most applications, so the 1st frame will actually be the 25th frame. It's more consistent than -ss, because the frame will be exact. If you use -ss, the start frame might be different depending on the frame rate of the source video.

    So it might look something like this as a batch file
    Code:
    for %%a in ("*.mpg") do ffmpeg -i "%%a" -vf_trim=start_frame=24 -an "output\%%~na.gif"
    pause
    But there are other considerations you might want to think about.

    -mpg2 is almost never square pixel (normally you would resize to the proper square pixel format with correct aspect ratio),

    -"gif" has many options and considerations for optimization. Frame rates are important. If source framerate is 29.97, it will be a problem with many browsers. Usually you should use 15 or less. Dithering algorithms are important as well for quality and filesize
    Quote Quote  
  4. How to generate animated GIF with optimized palette with ffmpeg:
    https://forum.videohelp.com/threads/377995-What-s-wrong-with-Solveig-Video-Splitter-s-G...=1#post2440729

    The -ss option is used to trim the start off a video. Here's a batch file that builds an optimized palette from the entire video and then produces an animated GIF from the video after removing the first second:

    Code:
    "C:\Program Files\ffmpeg\bin\ffmpeg" -i %1 -vf palettegen %1.palette.png
    "C:\Program Files\ffmpeg\bin\ffmpeg" -i %1 -i %1.palette.png -lavfi paletteuse -ss 00:00:01.000 %1.gif
    del %1.palette.png
    You can drag/drop video files onto the batch file. It will delete the palette file when done. The GIF file will have the same name (including extension) as the source, with .gif appended.

    You could easily modify this to operate on all video files in a folder.
    Quote Quote  
  5. I also support ffmpeg suggestion - to improve quality and reduce framerate this can be added to filter chain in ffmpeg:
    Code:
    tblend=all_mode=average,decimate=cycle=2
    Quote Quote  
  6. I'm a MEGA Super Moderator Baldrick's Avatar
    Join Date
    Aug 2000
    Location
    Sweden
    Search Comp PM
    Quote Quote  
  7. Member
    Join Date
    May 2016
    Location
    Munich
    Search PM
    Originally Posted by jagabo View Post
    How to generate animated GIF with optimized palette with ffmpeg:
    https://forum.videohelp.com/threads/377995-What-s-wrong-with-Solveig-Video-Splitter-s-G...=1#post2440729

    The -ss option is used to trim the start off a video. Here's a batch file that builds an optimized palette from the entire video and then produces an animated GIF from the video after removing the first second:

    Code:
    "C:\Program Files\ffmpeg\bin\ffmpeg" -i %1 -vf palettegen %1.palette.png
    "C:\Program Files\ffmpeg\bin\ffmpeg" -i %1 -i %1.palette.png -lavfi paletteuse -ss 00:00:01.000 %1.gif
    del %1.palette.png
    Hi guys,

    thx a lot for the hints, ffmpeg with the above script works perfect for me, thatīs what i was looking for!

    Kind regards,
    Markus
    Quote Quote  
  8. You can operate on all AVI files in a folder using a second batch file:

    Code:
    for %%a in ("*.avi") do GifTrim "%%a"
    That will call the earlier batch (GifTrim.bat) file to process each file. Change the ".avi" to ".mp4" to operate on MP4 file, etc.
    Quote Quote  



Similar Threads

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