Saturday, July 7, 2012

Messing with SWF (Flash files)

I wanted to extract the music from a flash file I was viewing, so I looked at the source code for the web page and found the link to the SWF file.  I downloaded this directly using curl
curl -O http://address.goes.here

I tried to play it in mplayer, no dice, similar with ffmpeg.  Some googling later revealed that I could either attempt to convert the full thing to video, or I could just extract what I needed.  I went with the later, using SwfTools

(thanks to Doesn't Not Compute for the pointers)

Google found this older FAQ for SwfTools which I used - I followed the instructions under (4) and installed freetype and jpeglib first (in case I want to do more advanced stuff with SwfTools later).  After I configured and compiled each of these, I configured and compiled SwfTools.  I was then ready for fun.

I followed (14) from the FAQ to extract

  1. I listed everything in my SWF:
    • swfextract downloaded.swf
  2. From the list I saw the last entry was "[-m] 1 MP3 soundtrack".  I was able to extract it with:
    • swfextract -m downloaded.swf
    • (result sent to output.mp3)
  3. Success!