Discussion:
Create overlay animated gif from youtube video stills on Windows 10 with freeware
Add Reply
Joe Scotch
2017-06-18 23:19:12 UTC
Reply
Permalink
Raw Message
I have a one-time need to create an animated GIF overlay on Windows from a
YouTube animation. I just did it the first way I thought of doing it.

I just ask your advice on how to improve the process using basic freeware
on Windows.

<1> Here is the original youtube video animation.


<2> Here are a few hundred same-sized JPEG screenshots every 1/10th of a
second using Irfanview freeware automation on Windows.
"Loading Image..."

<3> Here is the new layer that will be overlayed onto each of those JPG
screenshots drawn with Paint.net freeware.
"Loading Image..."

<4> Here is that same overlay file with the underlying layer removed so the
only layer left is the red lined boundary PDN file I want superimposed on
every screenshot (this file is a GIF only because the PDN would not
upload).
"Loading Image..."

<5> In Irfanview batch mode, I use "Add watermark image" to batch overlay
the single-layer boundary.pdn on top of every screenshot JPG file.
"Loading Image..."

<6> Assemble the JPGs into an animated GIF using ffmpeg from Imagemagick
freeware on Windows.

The convert command on Windows doesn't seem to be from Imagemagick.
https://stackoverflow.com/questions/3688870/create-animated-gif-from-a-set-of-jpeg-images
https://stackoverflow.com/questions/6230353/how-to-create-gif-animation-from-a-stack-of-jpgs
c:\> convert -delay 15 -loop 0 *.jpg animation.gif

So I'm stuck using ffmpeg which is from Imagemagick.
c:\> ffmpeg -f image2 -framerate 9 -i *.jpg out.gif

The last step is the part that isn't working since the files aren't being
found and all the help uses confusing %% syntax.
Joe Scotch
2017-06-19 00:31:13 UTC
Reply
Permalink
Raw Message
Paul
2017-06-19 01:38:08 UTC
Reply
Permalink
Raw Message
Post by Joe Scotch
The convert command on Windows doesn't seem to be from Imagemagick.
https://stackoverflow.com/questions/3688870/create-animated-gif-from-a-set-of-jpeg-images
https://stackoverflow.com/questions/6230353/how-to-create-gif-animation-from-a-stack-of-jpgs
c:�> convert -delay 15 -loop 0 *.jpg animation.gif
After some effort I realized that the "convert" from ImageMagick is
considered a "legacy" command of Imagemagick, which has to be expressly
installed by un default since the default is not to install it.
Loading Image...
So now I just have to get the ImageMagick Windows "convert" syntax to work
out right with the file names I have from Irfanview.
06/18/2017 09:19 PM 74,433 capture_544_18062017_211913_513.jpg
06/18/2017 09:19 PM 74,422 capture_545_18062017_211913_633.jpg
06/18/2017 09:19 PM 74,422 capture_546_18062017_211913_733.jpg
06/18/2017 09:19 PM 74,444 capture_547_18062017_211913_846.jpg
06/18/2017 09:19 PM 71,756 capture_548_18062017_211913_946.jpg
06/18/2017 09:19 PM 68,991 capture_549_18062017_211914_086.jpg
This created a 175MB animated GIF from 450 of those files above.
C:\> convert -delay 15 -loop 0 *.jpg animation.gif
Do you suggest how to make the animated GIF file size MUCH smaller?
Animated GIF can have a color-table-per-frame as one mode.
That's probably how yours is rendered right now.

There is an alternative preparation, where the output file has
one color table at the beginning, and no frame after that carries
a color table. On material intended for GIF in the first place,
you can cut the file size in half.

If you were expecting to cut the file size by 100, you need
a video compressor for that. Video compressors do lossy
compression at around 100:1 . GIF has lossless compression,
but only saves a lot of space on "solid" color like a Micky
Mouse cartoon. If I had cels like this, I could make a
very compact result.

Loading Image...

You should be doing a search on "convert video to animated gif"
to find a better tool for doing this. While you probably
can do it by hand, that's a lot of unnecessary work. If the
source material was Mickey Mouse, little preparation work
would be required. If the source is MP4 on the other hand,
you should just use a tool designed for that conversion
(as some serious math might be required to get the best
output file size).

Paul
Joe Scotch
2017-06-19 05:08:28 UTC
Reply
Permalink
Raw Message
Post by Paul
You should be doing a search on "convert video to animated gif"
to find a better tool for doing this.
I agree that it would probably be easier to save the Youtube video as an
avi and then just use ffmpeg on that avi to overlay the boundary.

Nonetheless, here's the best I can get, by playing with the numbers.

Starting with this time-lapse ice-sheet video from 1990 to 2015.
http://youtu.be/8pSayVWAVgI

Use Irfanview to snapshot every 1/10th of a second to JPG files.
. Irfanview: Options > Capture/Screenshot
Loading Image...

The files have a naming format as follows (by default):
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342.jpg
06/19/2017 05:39 AM 74,232 capture_148_18062017_211830_091.jpg
06/19/2017 05:39 AM 72,367 capture_164_18062017_211831_841.jpg
06/19/2017 05:39 AM 71,976 capture_180_18062017_211833_592.jpg
06/19/2017 05:39 AM 73,563 capture_195_18062017_211835_240.jpg
etc.

Step through the JPGs to collect only the summer July/August screenshots.
This is to make an apples-to-apples comparison animated GIF.

Make about 10 copies of the first and last slides, calling them:
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342a.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342b.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342c.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342d.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342e.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342f.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342g.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342h.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342i.jpg
06/19/2017 05:38 AM 73,851 capture_132_18062017_211828_342j.jpg
06/19/2017 05:39 AM 74,232 capture_148_18062017_211830_091.jpg
06/19/2017 05:39 AM 72,367 capture_164_18062017_211831_841.jpg
etc.
This is just so that the starting & ending points are easily seen.

Create an ice-boundary outline on the first file's ice sheet:
Loading Image...
. Paint.Net: Layers > Layer Properties > Background > [x]Visible > OK
. Paint.Net: Layers > Add New Layer
. Paint.Net: Choose a color
. Paint.Net: Draw the boundary of the summer ice
. Paint.Net: Layers > Layer Properties > Layer 2 > [ ]Visible > OK
. Paint.Net: Layers > (background) Delete Layer
. Paint.Net: File > Save As > boundary.pdn

This step above is a bit tricky, so I'm not sure if I captured the correct
steps exactly - but if you play with the files, you'll finally get just the
outline with everything else gone.

In hindsight, I shouldn't have used the Paint.Net "pencil" tool because it
doesn't have a thickness and I really should have made it thicker. Lesson
learned.

Add that PDN boundary to all the collected summer screenshots:
Loading Image...
. Irfanview: Batch conversion > Use advanced options > Advanced
. Irfanview: Advanced > Add Watermark Image > Settings > boundary.pdn
. Overlay start corner = top left
. Overlay transparency 10% (darkest, the overlay blocks out 90% of the
light)
. Overlay transparency 33% (i.e., the overlay blocks out 66% of the light)
. Overlay transparency 50% (i.e., the overlay blocks out 50% of the light)
. Overlay transparency 60% (i.e., the overlay blocks out 40% of the light)
. Overlay transparency 75% (lightest, the overlay blocks out 25% of the
light)

The problem here is that I can't find a good transparency level.
The lower I make the transparency percentage, the darker the background.
The higher I make the transparency percentage, the lighter the red line.

I want the opposite of that.

I want the red line to stay dark and the background to stay light. Sigh.

Create the animated GIF (which turned out to be about 20MB):
. C:> convert -delay 10 -loop 0 *.jpg summer_ice_10.gif
. C:> convert -delay 15 -loop 0 *.jpg summer_ice_15.gif
. C:> convert -delay 30 -loop 0 *.jpg summer_ice_30.gif

This made the file size only 2MB but it MERGED the data (which is bad!):
. C:> convert -delay 30 -loop 0 *.jpg -fuzz 10% -layers Optimize
summer_ice.gif

This didn't save anything in file size; it was still 20MB:
. C:> convert -delay 30 -loop 0 *.jpg -fuzz 10% summer_ice.gif

This made the file size 8MB and preserved the integrity of the data:
. C:> convert -delay 30 -loop 0 *.jpg -layers Optimize summer_ice.gif
Post by Paul
Animated GIF can have a color-table-per-frame as one mode.
That's probably how yours is rendered right now.
There is an alternative preparation, where the output file has
one color table at the beginning, and no frame after that carries
a color table. On material intended for GIF in the first place,
you can cut the file size in half.
If you were expecting to cut the file size by 100, you need
a video compressor for that. Video compressors do lossy
compression at around 100:1 . GIF has lossless compression,
but only saves a lot of space on "solid" color like a Micky
Mouse cartoon. If I had cels like this, I could make a
very compact result.
http://www.fantasiescometrue.com/images/medium/fct_f66fbeaa01ce61d.jpg
You should be doing a search on "convert video to animated gif"
to find a better tool for doing this. While you probably
can do it by hand, that's a lot of unnecessary work. If the
source material was Mickey Mouse, little preparation work
would be required. If the source is MP4 on the other hand,
you should just use a tool designed for that conversion
(as some serious math might be required to get the best
output file size).
Paul
Loading...