Forum Settings
Forums
New
Mar 15, 2013 11:21 PM
#1

Offline
Apr 2012
181
Whats a GIF you ask? Just in case you don't know, a GIF is an picture file with multiple frames and are usually animations or slideshows. Often those frames are directly ripped from a video of some kind and display a scene like in this GIF example below:


UPDATE: 10/08/13


How to make an animated GIF from your videos:

Step 1:
Download and install this free software.


CCCP: Don't needed anymore
http://www.cccp-project.net/download.php?type=cccp
You may already have the CCCP to watch anime, but for those who use the VLC instead of codec packs, is important to have the pack installed in order that the script uses DirectShow.


Avisynth 2.5:
http://sourceforge.net/projects/avisynth2/files/latest/download?source=files
This software is a powerful script tool for video post-production. Used by most of the anime encoders.

FFMS2:
http://ffmpegsource.googlecode.com/files/ffms-2.17.7z
DLL for Avisynth, help with the load of all kind of video files, with frame accuracy.
Decompress in "C:Program FilesAvisynth2.5plugins" folder.

VSFilter: Optional: to keep subtitles.
http://vsfiltermod.googlecode.com/files/VSFilterMod.zip
DLL for Avisynth to embed styled subtitles in the video. Also support non standard ass tags.
Decompress in "C:Program FilesAvisynth2.5plugins" folder.

AvsPmod:
http://www.amvhell.com/avspmod/AvsPmod_v2.4.2.zip
Script editor for Avisynth with many useful functions.
Installation not required, just unzip in a folder of your selecction.

VirtualDub:
http://sourceforge.net/projects/virtualdub/files/virtualdub-win/1.9.11.32842/VirtualDub-1.9.11.zip/download
Video capture/processing utility with many useful functions.
Installation not required, just unzip in a folder of your selection.


Step 2:
Get the video you want to make the GIF.


Step 3:
Open AvsPmod and go to File - Open.
Select Source files and open the video file.


Change "DirectShowSource" by "FFVideoSource":
<pre>FFVideoSource("D:/Downloads/Video/Chuu2/Chuu2-02.mkv")


Press "Next Frame" button, the video should load and you will be able to watch the video frame by frame.


Optional:
If you want to keep the softsubs, first Demux the ass/ssa/srt file from the MKV with MKVExtract.
Drag the ass/ssa/srt file to AVSPmod and change "DirectShowSource" by "TextSubMod":
<pre>TextSubMod("D:/Downloads/Video/Chuu2/Chuu2-02.ass")


Then find the part of the video you want to make GIF with the bottom slider, and look at the number of frame. Then add in a new line:
#Trim(0,0)
and replace the first 0 with the number of the frame you want the gif start, and the second with the last frame.
<pre>#Trim(27651,28108)

NOTE: in case you want to make a gif from different parts of the video just add another Trim with "+" without spaces between the first an the second:
<pre>#Trim(27651,28108)+Trim(28202,28309)


Then remove the leading "#", and go to the first frame with the bottom slider. Click on the Play/Pause button to see the preview of your gif.


NOTE: if you want a GIF with reverse loop just modify the Trim line and add something like this:
<pre>a=Trim(16215,16484)
b=Reverse(a)
a+b


If it's OK, save the script as AVS, and close AvsPmod. If not, adjust the trims.


Step 4:
Open VirtualDub, and open the avs script in "File - Open Video File".
You must see 2 video frames(depend on your screen and the video resolution, you can't see the second video frame)
Fullscreen VirtualDub(big image)
NOTE: right click in the first video frame and adjust the zoom to 50% or less.

Go to "Video - Filters", here we add 1 or 2 filters to obtain the final resolution of the gif.
If you need to crop the gif to a specific part of the screen, press "Add..." button and find "Null Transform" and press OK.
Then press "Cropping..." button, and adjust the margins to obtain just the part you want. Keep in mind the final size and the aspect ratio of your desired gif.

Press "Add..." again(of for first time if you don't crop the video file) and search "Resize". Here we can resize the video to obtain a small gif. Depend of what do you want to do with the gif is the size you put in this field, as Absolute size(in pixels) or Relative(%). I recommend to keep the same aspect ratio from the source(default option). Press OK button and press OK again.

You must see the second video frame at the final size. If it's OK, then we are ready to save as GIF.


Go to "File - Export - Animated GIF...".

Select the name and folder to save the GIF by pressing "...", and select Infinite loop.

Click OK and wait until the program finishes, and close VirtualDub.

You now get an animated GIF with the best quality possible(as the GIF only support 256 colors).
GIF


OPTIONAL:
You can modify the GIF with an image editing software to improve some aspects, but with the last step most of you get a fully functional GIF for whatever you want.


Outdated:



PS: IMG tag issue... when come back the BBCode I'll update the post.
al_exsMar 18, 2014 3:05 AM
Reply Disabled for Non-Club Members
Mar 15, 2013 11:58 PM
#2

Offline
Apr 2012
181
Color compression is only available if you work with the video for encode, but to make a gif not(as far as I know in VirtualDub). But I use Photoshop to improve the GIF colorspace compression in order to reduce some Kb/Mb in the size of the gifs.

To change the frames per second, go to Video - Frame Rate, but if you load directly the video file with the avs, the frame rate should be the same from the video source.

There are some others features in VirtualDub, but I just start learnig to use it, and IDK others aside video filters in VirtualDub, as far as I just use it for preview my avs scripts.

For Apng, instead of export the composition as GIF, you can Export as Image Sequence, and choose PNG, and then with some other tool make an APNG.

And yeah, this method add automatically the subtitles from the file, and if you don't want them in the GIF, the trick for softsubs is re-mux the MKV without subtitles using MKVMerge from MKVToolnix. In this fansubbing group from what I get the video, they put dialogues in softsubs and some other edition and FX goes hardcoded to the video.
al_exsOct 8, 2013 12:02 AM
Mar 16, 2013 12:35 AM
#3

Offline
Feb 2010
11732
Looks like an extremely good tutorial! I'll test it out later this weekend hopefully. I would like an easy way to make these kinda gifs in HQ.

imo you should separate the different steps in quotes and each step heading in bold- it tends to make long tutorials (which these can't help being) less intimidating and ppl are more likely to try it.

btw funny thing I used to make GIFs like this back in 2006-days by screencapping an entire scene then pasting all the screenshots together, so tedious compared to nowadays...
Oct 4, 2013 7:39 AM
#4

Offline
Jan 2012
3
Thank you for this step-by-step guide on making Animated GIFs~! <3 It was very easy to follow, and the links provided for the programs to create and edit GIFs were wonderful additions!
Thank you very much for this!

However, I do have a few question that I would like some assistance with.
1. How do I keep subtitles in GIF?
2. How do I create a reverse loop GIF like this (http://i41.tinypic.com/1hte7q.jpg) with the programs you have provided? [The one done by Shishio-kun on his How to loop GIFs more fluidly forum post.]

For question 1, I did not do anything out of step or change any settings during the portion where I use AvsPmod to acquire .avs file. I used ZenSub's InuHasa video with softsubs as gif material. (Just a random seen with nice tits.)
yukari_yakumo17Oct 4, 2013 7:45 AM
Oct 6, 2013 10:04 PM
#5

Offline
Apr 2012
181
yukari_yakumo17 said:

1. How do I keep subtitles in GIF?

Well, if subtitles don't show try open Haali Media Splitter Settings, In Options tab find "Autoload VSFilter" and change to "yes" and Accept Changes. Then try again and subs should show now.

In case of the subs don't show download and paste the next dll in C:\Program Files\Avisynth2.5\plugins\
http://vsfiltermod.googlecode.com/files/VSFilterMod.zip

Demux de subs with MKVExtract to obtain an .ass/.ssa/.srt file. In the avs put something like this:
DirectShowSource("Original video.mkv", audio=false)
TextSubMod("Subs File.ass")


And all the next steps just like in the tutorial.

yukari_yakumo17 said:

2. How do I create a reverse loop GIF like this (http://i41.tinypic.com/1hte7q.jpg) with the programs you have provided? [The one done by Shishio-kun on his How to loop GIFs more fluidly forum post.]

Well this can be done by several ways, one of them in the avs Script.

Just follow the steps but just before the Step 4 change a little the last line(the one with the Trims):
a=Trim(16215,16484)
b=Reverse(a)
a+b


That code paste a reverse clip just after the normal clip, and go to Step 4 normally, and that is the way to reverse loop a file in Avisynth.
Oct 7, 2013 5:37 AM
#6

Offline
Jan 2012
3
Thank you very much~! <3

Your quick response and wonderful answering skills have helped me to further my GIF POWERS!
Seriously, you are a wonderful help and inspiration, and with my busy schedule I don't have time to learn fancy coding and computing skills to make the most ELITE of GIFS.
I needed something simple, quick, and easy to get me started, and, you, my gentleman of the internet are a CHAMPION OF LOVE~! <3

I may continue to come to you for assistance and with questions, so I would like to apologize for further intrusions into your BUSY LIFE. :(

Thank you and have a pleasant DECADE~! <3
Oct 8, 2013 12:00 AM
#7

Offline
Apr 2012
181
Post Updated, but now with no pics cuz the BBCode... D:
Oct 8, 2013 12:52 AM
#8
Offline
Jun 2012
40
The new update really made this godly. Thanks a lot for this.
Oct 14, 2013 1:41 AM
#9

Offline
Feb 2013
459
I have problem with step 3, namely i did all like in steps before but when im lunching AvsPmod and my video, program shows error: there is no function named FFVideoSource. What i can do with it?

Oct 14, 2013 2:44 AM

Offline
Apr 2012
181
Download FFMS2:
http://ffmpegsource.googlecode.com/files/ffms-2.17.7z
and decompress in "C:/Program Files/Avisynth2.5/plugins/" folder, but do not copy the folder, only the content of it:
-FFMS2.avsi
-ffms2.dll
-ffmsindex.exe
al_exsOct 14, 2013 2:47 AM
Mar 18, 2014 12:39 AM

Offline
Jan 2012
160
Hello. I have the same problems as Thiv...
I did download FFMS2 and extract the contents of the FFMS2 folder into C:/Program Files/Avisynth2.5/plugins/.

I tried with the "doc" folder existing and without it [extracting the content of doc into plugins folder itself]. Both methods still yield me with a "error: there is no function named FFVideoSource".

The only thing that works so far was with an AVI file and with trimming different two different sections of the video... otherwise, I end up with really bad, stuttering gifs even with avi files.
Mar 18, 2014 2:56 AM

Offline
Apr 2012
181
Extracting the files in the Avisynth plugins folder should work, but if not try with this other dll, unzip this ffmpegsource.dll in the plugins folder.
Mar 19, 2014 10:39 PM

Offline
Jan 2012
160
Unfortunately, I still receive the same error even after extracting the ffmpegsource.dll file into the C:/Program Files/Avisynth2.5/plugins/.

Proceeded to open AvsPmod, changed the beggining to FFVideoSource (has a smiley face icon instead of a check; not sure what this means) but I can't open mkv files as I stated. So far, I can only open avi files with the avi coding 'prefix', "AVIFileSource" but that ends up yielding a low quality, stuttering gif once I follow through with the steps.

I'll try a reinstall of everything.

Edit: still get the same error...I really don't know what I'm missing? Is it somehow because my AvsPmod is located in my 'Documents' and somehow doesn't detect or load the plugins from AviSynth2.5 from C drive?
Lt_SpinzakuMar 19, 2014 10:50 PM
Mar 19, 2014 11:08 PM

Offline
Apr 2012
181
C:/Program Files/Avisynth2.5/plugins/


You have 32-bit windows?

If you have 64-bit windows then that's the problem, 'cause 64-bit version of avisynth doesn't work with AvsPmod, must be the 32-bit version no mater the OS.

On the other hand, in AvsPmod verify the Program Setting in Options Menu.

Try to change the directory of Avisynth by checking the check box and select the path to Avisynth folder, accept and restart AvsPmod. If still not working, need to check the steps you follow to install Avisynth.
Mar 21, 2014 8:22 AM

Offline
Jan 2012
160
al_exs said:
C:/Program Files/Avisynth2.5/plugins/


You have 32-bit windows?

If you have 64-bit windows then that's the problem, 'cause 64-bit version of avisynth doesn't work with AvsPmod, must be the 32-bit version no mater the OS.



Ah, I must have downloaded the 64 but version avisynth.

Thanks for the responses! I'll try this out again soon!
Jan 10, 2015 6:15 PM

Offline
Aug 2014
432
How can I prevent the quality loss when I'm exporting as a gif?

I got this as a source http://i.imgur.com/XISGpAG.png but when I export it as a gif, the quality is worse http://gfycat.com/IllustriousChubbyGavial

I do realise that gifs can only have 256 colors, but how can some of them looks much better?

To compare, I used a gif I found on the internet and tried to reproduce it(look at the backgrounds) : http://i.imgur.com/sbOKuCH.gif
versus mine:
http://i.imgur.com/FK5GnUl.gif

The difference is more subtle on this gif though but I made a picture to show you what I meant: http://i.imgur.com/y4g8H9B.png
SatiriquesJan 10, 2015 6:57 PM
Jan 10, 2015 7:03 PM

Offline
Apr 2012
181
You can't, the GIF specification only have 256 colors(PNG can have 16777216 colors), so that's why when you save it as GIF loses quality.

The only way to keep the quality of the fist image is making an APNG(Animated PNG), but that isn't a standard and accepted format, only Firefox show them wright and Chrome with the APNG extension.

But the tools to make the APNG are only from command line.
Jan 10, 2015 8:41 PM

Offline
Aug 2014
432
al_exs said:
You can't, the GIF specification only have 256 colors(PNG can have 16777216 colors), so that's why when you save it as GIF loses quality.

The only way to keep the quality of the fist image is making an APNG(Animated PNG), but that isn't a standard and accepted format, only Firefox show them wright and Chrome with the APNG extension.

But the tools to make the APNG are only from command line.


I'm sorry, I think I didn't really explain with the right terms. What I meant is fixing the dither on the gif so the color change isn't as drastic. However, I did find an easy way to fix that after looking on the internet, here's what I did: I used Virtual dub and I changed video to 10fps and then I exported it as an Image sequence. Finally, I used gimp and changed the image mode to indexed(8 bit color) with a dither filter.

Here's the difference:
Without the filter http://i.imgur.com/bJSrBha.png

With the filter http://i.imgur.com/PkthcPu.png

And the final product http://i.imgur.com/q01TGO1.gif

It's not really that much more complicated and it look a little bit better in my opinion.
SatiriquesJan 10, 2015 9:32 PM
Jan 18, 2015 3:09 PM

Offline
Apr 2012
181
Oh, that, is an issue of VirtualDub way of saving the GIF, as it doesn't have any option to optimize them.

I use Photoshop to fix the dithering but as you say, changing to 10 fps and save as separate images and then create the GIF in another program is the best way to get ride of that.

I'll update this soon to add your advice and something else.
Mar 10, 2016 4:53 PM

Offline
Jul 2013
133
I now use this to make gifs faster, seems to almost equal photoshop if the right dithering is choosed.

This method needs reencoding, but it takes only a few seconds on a powerful computer, and less than a minute on a very weak one by today's standards. And it is way faster than installing lots of GUI.

All starts with the script :
http://mavericktse.mooo.com/wordpress/archives/2084Dead, providing mega link below :
https://mega.nz/#!uJFymTrD!pVVVVFBtr2s-SIeCWBmswLbfMa-J8pP9E_Eg-NAquFo
You need ffmpeg.exe, gifdiff.exe and gifsicle.exe in the same folder.


You also need to install everything from first post (leave only VirtualDub, not required), and get the last x264 binary from here (not the 10bit version) : Edit : providing a link with mp4 support, use "clear" x86 version. http://komisar.gin.by/
You may also need Aegisub if you encounter trouble with the frame count.

I see some links from first post are dead, and I know these are not the most easy to find. Avisynth link is still good, here are the missing ones.

http://ffmpeg.org/

https://github.com/FFMS/ffms2/releases
(put the x86 version of these in your avisynth plugin folder : http://i.imgur.com/GdyQoMB.jpg)

VSfilter if subs desired (also goes in your avisynth plugin folder) :
https://sourceforge.net/projects/guliverkli/files/VSFilter/VSFilter%202.37/

1. create a file with notepad filled with the following code :
FFVideoSource("source.mp4")
#If subs needed
#TextSub("subs.ass")
Trim(xxxx,xxxx)
LanczosResize(768,432,0,0.5)
ChangeFPS(10)

Then rename it with .avs instead of .txt. You can now open it with avspmod.

Change resize with any suitable one (not Lanzcos but Bicubic if less sharpening is desired, or LanczosResize(480,272,0,0.5) for a smaller pic), this is for 16/9 video ratio. You can use any commands from first post instead of the simple Trim, and preview the file in AvsPmod)

If you encounter trouble with incorrect frames numbers in AvsPmod, use Aegisub to get the right ones (Open video, click on video cursor, and seek with left/right arrows).

Of course, replace source.mp4 with any video you want (.mkv works too), and set the correct start and end frame numbers instead of the xxxx for the script to work.

2. create a file with notepad filled with the following code :
@echo off
cls
SET video_input="script_created_before.avs"
SET video_output="output"
SET q=16
time/t
"x264.exe" --output %video_output%.mp4 %video_input% --crf %q%
pause


Rename it with .bat instead of .txt (x264 binary and the .avs must be the same folder. Replace x264.exe with your real binary name, and script_created_before.avs with your real script name)

3. Drag & Drop the resulting video on the .vbs (don't forget to add the required binaries of ffmpeg, gifdiff and gifsicle in the same folder as the .vbs)
Choose 256 colors, 10fps, dither method #0 (bayer), then accept all default settings.

You will obtain two .gif images, one is optimized with less frames and thus has smaller filesize (less than a Ko saved for me), so take this one anyway.

Edit 2 : a nice example, with loop code
a=Trim(xxxx,xxxx)
b=Reverse(a)
a+b
NoblueskyNov 10, 2017 2:20 PM
Reply Disabled for Non-Club Members

More topics from this board

» ✳️ Bunkasai 2024 List Design and Graphic Design contests are OPEN

Shishio-kun - Nov 18

2 by Shishio-kun »»
Nov 18, 5:01 AM

Sticky: » [ SIGNATURES ~ PROFILES] All guides, generators, and templates

Shishio-kun - Feb 16, 2023

29 by floral_sacrifice »»
Nov 15, 10:24 AM

» [CSS - Modern] 🍰 Clarified by V.L — a responsive table-based design ( 1 2 )

Valerio_Lyndon - Aug 1, 2022

94 by ddaruu »»
Nov 13, 9:18 AM

Sticky: » [ BBCODE ] All 2023 BBcodes, Guides, and Templates ( 1 2 )

Shishio-kun - Feb 16, 2023

55 by _cjessop19_ »»
Nov 12, 4:45 AM

» Load all entries at once in modern style?

tirafesi - Nov 3

1 by Shishio-kun »»
Nov 7, 1:44 AM
It’s time to ditch the text file.
Keep track of your anime easily by creating your own list.
Sign Up Login