Jump to content

Encoding Animated GIF with ffmpeg.


Recommended Posts

In case anyone wants to know how to encode an animated GIF with ffmpeg, here is a quick explanation...

 

First of all ffmpeg is a very good and powerful encoder, I use it quite a bit with various programs or in Batch Processing via a batch file. I'm just going to explain the batch file process for now. Download ffmpeg in either 32-bit or 64-bit versions and put the ffmpeg.exe somewhere on your HDD. You can create a folder called ffmpeg in you C:\ drive if you'd like. Open Notepad and paste the following script and save as animated_GIF.bat:

 

SET PATH="C:\FFMpeg"

for %%a in ("*.avi") do ffmpeg -i "%%a" -vf scale=320:-1:sws_dither=a_dither -r 10 -ss 00:00:04 -t 00:00:08 -pix_fmt rgb8 -loop 0 -an "%%~na.gif"
pause

 

The 1st line is the path to the folder where ffmpeg.exe is located. Edit as needed.

("*.avi") means it will process all avi's in a folder. You can change it to ("*.mp4") for example to process mp4's.

-vf scale=320:-1 means it will resize the width to 320, the height will auto resize to keep aspect ratio intact.

-r 10 means 10 fps.

-ss 00:00:04 means it starts encoding at the 4 second point.

-t 00:00:08 means it will encode a total of 8 seconds of footage.

 

You can also create an animated apng file in Paint.net, the use ffmpeg to encode the apng file into an animated GIF. Just omit the -r, -ss and -t  commands. 

 

Then just drag you file into the animated_GIF.bat file and all files with the associated extension in the folder will be processed.

 

Here is a quick example where I encoded a 12 year-old camcorder clip resized to 320 x 213.

post-140007-0-19283500-1423270787.gif

 

Edited by racerx

Plane_Sig2.gif

Link to comment
Share on other sites

What's this to do with paint.net?

Link to comment
Share on other sites

What's this to do with paint.net?

 

The point is that you can make an animated GIF with Paint.NET using Simon Brown's plugin, but the quality is poor and file size is high. You can make an animated apng file using the same method, then drag the animated.apng file into an ffmpeg batch file to make a decent quality animated GIF at a low file size.

 

Sure you can make a VP9.webm file also, but support for that is very low. You have little options other than youtube upload. There is also an option for animated.webp, but again low support.

 

Anyway, if you think this is irrelevant, you can go ahead and delete it.

Plane_Sig2.gif

Link to comment
Share on other sites

I'm not going to delete this thread. I just didn't see the connection. Your explanation is an excellent justification for this thread. Thanks.

Link to comment
Share on other sites

Thanks so much @Racerx - I've always been facinated with animation, but have found the subject difficult.  I will be trying your suggestions - look out........ I may post something soon (if I'm not too old to figure this out) crutches.gif

30b8T8B.gif

How I made Jennifer & Halle in Paint.net

My Gallery | My Deviant Art

"Rescuing one animal may not change the world, but for that animal their world is changed forever!" anon.

 
Link to comment
Share on other sites

Thanks so much @Racerx - I've always been facinated with animation, but have found the subject difficult.  I will be trying your suggestions - look out........ I may post something soon (if I'm not too old to figure this out) crutches.gif

 Racerx  thanks from me to.  looks  workable for me ( -I slow some times)

 

 

An Pixey ;

Pixeys don't get old, they just get cleverer and cleverer and clev......well you get the idea 63037d45.gif

           Scooter

  Age is only  a number --in my case a Really BIG number, but there you have it

When the prefect paint.net image is created, I will still be wondering "How they Do that?"- sigh☺️

       

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...