Page 1 of 1

[SOLVED] Bug with convert

Posted: 2016-01-13T16:58:47-07:00
by grigory
Hey guys,

I have a problem trying to split big animated GIF into frames (17Mb).
I use the following command:
/usr/local/bin/convert -coalesce /gifs/test.gif /gifs/result/%d.gif

This GIF has 150 frames and lasts 5 seconds with FPS=10 (I made it from video).
However, most of the time in a result folder I get from 45 to 65 files.
For some reason, last frame has only 10 bytes. Sometimes I get all 150 frames but it happens very rare.
Convert usually stops without any warnings and errors in 22-28 seconds.

Here is the animation -- http://countriesguide.com/test.gif

Any ideas?

P.S.: ImageMagick 6.9.1-3

Re: Bug with convert

Posted: 2016-01-13T17:38:27-07:00
by fmw42
try

Code: Select all

/usr/local/bin/convert /gifs/test.gif -coalesce +adjoin /gifs/result/test_%03d.gif

Re: Bug with convert

Posted: 2016-01-14T11:21:05-07:00
by grigory
Tried it twice -- got 31 and 41 frames while it has 150 frames. The last one had 10 bytes.
Also tried it on my second server (2xXeon, 24Gb RAM, ImageMagick 6.8.6-10), got 130 frames without adjoin and 108 with adjoin, last one also had 10 bytes. BTW, adjoin option makes the process much slower. My first server has Dual Core + 8Gb RAM.

Bug?

Re: Bug with convert

Posted: 2016-01-14T11:39:09-07:00
by snibgo
No problem on my computer.

How much free memory do you have? Q16 takes 8 bytes/pixel. Coalesce might double this, so that would be 553 MB. That isn't much these days, but it's worth checking.

Re: Bug with convert

Posted: 2016-01-14T12:14:58-07:00
by fmw42
Perhaps the tmp directory is getting too full

Re: Bug with convert

Posted: 2016-01-14T12:25:26-07:00
by grigory
No problem on my computer.
Do you use linux? Well, sometimes I get 150 frames. This happens in 4/10. Also I make test on a production servers, not an idle PC.
snibgo wrote:How much free memory do you have? Q16 takes 8 bytes/pixel. Coalesce might double this, so that would be 553 MB. That isn't much these days, but it's worth checking.
My servers have 8 and 24 GBytes RAM respectively. Or you meant some sort of memory per each IM proccess? If so, how can I check it?
Perhaps the tmp directory is getting too full
/tmp is mounted on /dev/shm which has 4 GBytes of space.

Please keep in mind guys, that I use 2 version of IM on 2 different servers with different hardware configuration.

Re: Bug with convert

Posted: 2016-01-14T12:52:26-07:00
by fmw42
OK. Let me understand. Sorry if you have to repeat. Do both systems have trouble? If not, which one and what version of Imagemagick.

I am on Imagemagick 6.9.3.0 Q16 Mac OSX (Mac Mini with 4GB RAM) and the following works fine and creates all your frames

Code: Select all

cd test1
convert test.gif -coalesce ../test2/test_%03d.gif

Re: Bug with convert

Posted: 2016-01-14T12:54:31-07:00
by snibgo
I'm on IM v6.9.2-5, Windows 8.1, 12 GB RAM. Servers sometimes limit memory to 1 GB per process. If you have >2 GB available, that's not the problem.

Re: Bug with convert

Posted: 2016-01-14T12:58:27-07:00
by fmw42
check your Imagemagick policy.xml file to see if anything else has been limited in IM otherwise, as snibgo says, check your server for other limitations.

Re: Bug with convert

Posted: 2016-01-14T21:24:00-07:00
by grigory
fmw42 wrote:OK. Let me understand. Sorry if you have to repeat. Do both systems have trouble? If not, which one and what version of Imagemagick.

I am on Imagemagick 6.9.3.0 Q16 Mac OSX (Mac Mini with 4GB RAM) and the following works fine and creates all your frames

Code: Select all

cd test1
convert test.gif -coalesce ../test2/test_%03d.gif
Yes, both servers have trouble (IM 6.8.6-10 and IM 6.9.1-3). That's why I opened this topic.
check your Imagemagick policy.xml file to see if anything else has been limited in IM otherwise, as snibgo says, check your server for other limitations.
I don't have anything policy.xml (all options are commented out). And what kind of check shall I make? As snibgo said, memory is not a problem in my case.

Re: Bug with convert

Posted: 2016-01-15T04:20:45-07:00
by magick
Perhaps you are running out of temporary space, typically /tmp. Set the MAGICK_TMP environment variable to a path that has copious amount of free space:
  • export MAGICK_TMP=/data/tmp
    convert -limit memory 2MiB -limit map 4MiB test.gif -coalesce ../test2/test_%03d.gif

Re: Bug with convert

Posted: 2016-01-16T11:33:23-07:00
by grigory
Oh guys, promise me you won't laugh :-D I found out what was the problem!
A couple of years ago I made a simple tool which kills any "convert" process after 40 seconds because of old IM bug when IM hanged my server.
So this tiny tool killed any convert process before it could prepare all the 150 frames of my .gif file :-D :-D :-D
And I had it running in memory 24/7 on both servers :-D

Re: [SOLVED] Bug with convert

Posted: 2016-01-16T11:35:40-07:00
by fmw42
Glad to hear it was that simple. Sometimes the simplest issue are the hardest to find.

Re: [SOLVED] Bug with convert

Posted: 2016-01-16T12:53:50-07:00
by grigory
Yeah, I spent many hours trying to find a bug in my code + PHP/Apache configs + IM :-D