Sunday, July 06, 2008

Rendering/exporting with Flash

Flash is not good at exporting (at least in my experience). It's not so fun to stay up really late finishing a project and then have to wrestle with exporting!

Here's what I do (thanks to Karl Sigler for showing me ffmpeg):

1. From Flash, export your animation as a PNG sequence. Most likely you don't want transparency, so pick "24 bit" instead of "24 bit with alpha".

2. Also from Flash, export just the soundtrack as a .WAV

3. Once that's done, join up the PNGs and WAV file like so:

ffmpeg -r 24 -i cartoon%04d.png -i cartoon.wav -b 900k cartoon.avi

"-r 24" means that your source animation is 24 frames per second. This is a good framerate to work in. Make sure this matches the number you have in your Flash file, though!

"-i cartoon%04d.png" tells ffmpeg where to find the PNG files. If you haven't done much programming the "%04d" may be confusing: it means "a four digit number padded by zeroes", and ffmpeg generates the filenames starting at 1. So in this case it would generate a series of filenames like "cartoon0001.png", "cartoon0002.png" and so on.

"-i cartoon.wav" tells ffmpeg to grab the soundtrack too.

"-b 900k" tells ffmpeg that the output movie should be 900 kbps. Depending on whether you're making a DVD or uploading to YouTube, you'll want to use different values here (the higher the number the higher the quality but the bigger the file also).

"cartoon.avi" is the output filename.

2 comments:

bryan elfboy said...

very nice

Adam said...

i used to go with this program, SWF2AVI. Basically you load your swf into it and leave it running and it will play the entire thing one frame at a time and output each frame as either a BMP or JPG. If that wasn't useful enough, it has a built in utility where you can input any number of images, specify the frame rate, and save as compressed or uncompressed AVI! I agree tho, Flash has serious problems when it comes to exporting...

hugs
Adam