Command line for converting .SWF to animated GIF

adobe-flashconversionffmpeg

I'm running Kubuntu. I don't want to install any Windows applications in wine. I would like a (relatively simple) command to convert a flash animation (.SWF file) to an animated GIF.

The input .SWF file is only 14.5 KiB and I want to convert the entire thing at best quality. I'm hoping the GIF will be of similar size.

Here's the info on the ffmpeg I have installed:

ffmpeg version 0.10.12-7:0.10.12-1~precise1 Copyright (c) 2000-2014 the FFmpeg developers
built on Apr 26 2014 09:49:36 with gcc 4.6.3
configuration: --arch=amd64 --disable-stripping --enable-pthreads --enable-runtime-cpudetect --extra-version='7:0.10.12-1~precise1' --libdir=/usr/lib/x86_64-linux-gnu --prefix=/usr --enable-bzlib --enable-libdc1394 --enable-libfreetype --enable-frei0r --enable-gnutls --enable-libgsm --enable-libmp3lame --enable-librtmp --enable-libopencv --enable-libopenjpeg --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-vaapi --enable-vdpau --enable-libvorbis --enable-libvpx --enable-zlib --enable-gpl --enable-postproc --enable-libcdio --enable-x11grab --enable-libx264 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static
libavutil      51. 35.100 / 51. 35.100
libavcodec     53. 61.100 / 53. 61.100
libavformat    53. 32.100 / 53. 32.100
libavdevice    53.  4.100 / 53.  4.100
libavfilter     2. 61.100 /  2. 61.100
libswscale      2.  1.100 /  2.  1.100
libswresample   0.  6.100 /  0.  6.100
libpostproc    52.  0.100 / 52.  0.100

Best Answer

You don't mention in your post if you've tried the most basic command that should accomplish this:

ffmpeg -i input.swf output.gif

Assuming that works there are going to be quality problems with it, because GIF is a 256-color format. (Imgur recently extended the file format for GIFV which uses WebM video, but that's a separate topic)

If that didn't work, it's because you don't have a SWF decoder or a GIF encoder. You can run this command to see what codecs/formats are supported by your version of FFMpeg:

ffmpeg -formats

The output of that is pretty verbose (it will list everything) and you can use grep to cut it down for you:

ffmpeg -formats | grep -i GIF
ffmpeg -formats | grep -i SWF

For me I get this:

 DE gif             GIF Animation
  E avm2            SWF (ShockWave Flash) (AVM2)
 DE swf             SWF (ShockWave Flash)

This shows that my version of FFMpeg supports decoding and encoding GIF and SWF.

You may also want to test converting it to an AVI before converting it to GIF, to see the quality before any GIF problems:

ffmpeg -i input.swf -sameq output.avi

It may get mad about trying to use the -sameq flag because SWF doesn't have a "quality". You could also try -b:v 900k to set the video bitrate to pretty high.

Update

The source you linked to can easily be compiled on any Linux system that has GCC and the "zlib" library (almost everything has that) Here is how I compiled it:

sudo apt-get install build-essential zlib-dev
wget -o main.c "http://svn.perian.org/ffmpeg/tools/cws2fws.c"
gcc main.c -lz

You can now run the tool to convert like this:

./a.out input.swf decompressed.swf

Cheers

Related Question