Extracting frames from HUGE animated gif

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Extracting frames from HUGE animated gif

Post by Rye »

So I have this animated gif , with -


don't freak out -

a few thousand frames:

http://tinyurl.com/odk78wu



The usual command:

Code: Select all

convert image.gif  image_%d.gif
will just crash and burn.

Any ideas on this one ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting frames from HUGE animated gif

Post by snibgo »

Movies, including large animations, are handled better by ffmpeg than by ImageMagick.

Code: Select all

ffmpeg -i toyrobo.gif f_%06d.gif
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Extracting frames from HUGE animated gif

Post by Rye »

This will however only extract the first frame of the gif...

how do I go on about extracting all ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
rich2005
Posts: 32
Joined: 2012-04-09T11:07:36-07:00
Authentication code: 8675308

Re: Extracting frames from HUGE animated gif

Post by rich2005 »

Your file seems to have vanished but..

try this syntax

Code: Select all

ffmpeg -i inputfile.gif -f image2 image-%07d.gif
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting frames from HUGE animated gif

Post by snibgo »

The command I gave extracted 230,370 frames. For further help, see ffmpeg documentation.
snibgo's IM pages: im.snibgo.com
rich2005
Posts: 32
Joined: 2012-04-09T11:07:36-07:00
Authentication code: 8675308

Re: Extracting frames from HUGE animated gif

Post by rich2005 »

@snibgo

Just a word of explanation, and I had to go and look it up as well.

The ffmpeg syntax changed from pre version 1.2.1

AFAIK the windows IM comes bundled with ffmpeg and uses an older version.
With Linux, ffmpeg is a separate package installed as a dependency and you get whatever version is in the repo, almost certainly post 1.2

The syntax I offered, pulled from my notes is not quite correct and produces jpeg encoded single files. (never bothered me in the past, very little to do with animations)

The correct syntax is

Code: Select all

ffmpeg -i infile.gif -c:v gif -f image2 outfile%07d.gif
A more universal way is convert to png where

Code: Select all

ffmpeg -i infile.gif outfile%07d.png

which should work regardless of ffmpeg version.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Extracting frames from HUGE animated gif

Post by snibgo »

Thanks.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Extracting frames from HUGE animated gif

Post by Rye »

This is odd...

I tried both ways provided, but only one image is extracted...
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Post Reply