Long story short, I’m currently creating about 2,000 small-ish .swf files. Each .swf consists of a single jpeg, used as a button, embedded with a small (2-3 second) audio file. When the button is clicked, the audio plays. Simple enough.
I’m trying to compress these files to as small a size as possible, while retaining the clarity of the audio to the point that you can still understand the words being pronounced. What I need, then, are suggestions for optimal settings for:
- The audio files (WAV or mp3, bitrate, etc)
- The Flash files (I’m only familiar enough with Flash to create the template I’ve got, so I’m not sure what settings are available)
- The tools to use to accomplish each…I have Flash CS3 Pro and SWiSHmax, Audacity, iTunes, and the standard Windows Media set on XP Pro. I’m perfectly willing to download and install any freeware apps as well.
I’ve tried playing around with this on my own, but not knowing much about how Flash works, the results are sometimes counterintuitive. Changing the bitrate on a WAV file didn’t have much effect on the final size of the .swf, and encoding it into .mp3 actually seemed to make things worse. Rather than try every possible combination of settings, compressions and codecs, I figured I’d ask if anyone had any better ideas.
So, any suggestions? If it’ll help, I can upload the template I’m currently using to my webhosting, but it ought to be fairly self-explanatory. Thanks in advance for any advice.
My first suggestion would be to see what your Flash compiler is actually doing to your sound file. You can do this, for example, with the freeware program swfdump (from swftools, the same utility library I mentioned in this earlier thread). You may find that the compiler is already converting to a low-but-fixed-fidelity MP3, in which case any compression you do to your source WAV will have little effect on the final file size.
For example, I stripped the arrow buttons out of the example I linked to in the previous thread, leaving just one button and one WAV file in the source:
###################################################
# Sound : embed Wav file and control it (+/-) #
# technoargia - avril 2006 #
###################################################
.flash filename=hello_friend.swf bbox=autocrop
.box container width=50 height=50 color=gray fill=white line=2
.box button_idle width=60 height=60 color=blue fill=salmon line=5
.box button_hover width=60 height=60 color=red fill=salmon line=6
.box button_pressed width=60 height=60 color=gray fill=salmon line=5
.sound hi "hello_friend.wav"
.outline o_play:
M 0,40 L 0,80 L 80,40 L 0,0 z
.end
.filled play_idle outline=o_play fill=#3366ff color=navy line=4
.filled play_hover outline=o_play fill=#336699 color=salmon line=4
.filled play_pressed outline=o_play fill=#4466ff color=red line=3
.button play
.show play_idle as=idle
.show play_idle as=area
.show play_hover as=hover
.show play_pressed as=pressed
.on_release:
player.Start();
.end
.end
.action:
player = new Sound();
player.attachSound("hi");
player.setVolume(10);
var i = 10;
.end
.put container
.put play pin=center x=25 y=25 scale=50% alpha=50%
.end
The source WAV file was 272K (16bit, 44.1kHz, 3.15s). The resulting SWF (compiled with swfc) was 11577 bytes long. swfdump gave the following statistics:
[HEADER] File version: 6
[HEADER] File is zlib compressed. Ratio: 86%
[HEADER] File size: 13384 (Depacked)
[HEADER] Frame rate: 50.000000
[HEADER] Frame count: 1
[HEADER] Movie width: 50.95 (left offset: -0.45)
[HEADER] Movie height: 50.95 (top offset: -0.45)
[309] 3 REFLEX
[009] 3 SETBACKGROUNDCOLOR (00/00/00)
[020] 35 DEFINESHAPE3 defines id 0001
[028] 12 NAMECHARACTER adds information to id 0001 "container"
[038] 14 EXPORTASSETS
exports 0001 as "container"
[020] 36 DEFINESHAPE3 defines id 0002
[028] 14 NAMECHARACTER adds information to id 0002 "button_idle"
[038] 16 EXPORTASSETS
exports 0002 as "button_idle"
[020] 36 DEFINESHAPE3 defines id 0003
[028] 15 NAMECHARACTER adds information to id 0003 "button_hover"
[038] 17 EXPORTASSETS
exports 0003 as "button_hover"
[020] 36 DEFINESHAPE3 defines id 0004
[028] 17 NAMECHARACTER adds information to id 0004 "button_pressed"
[038] 19 EXPORTASSETS
exports 0004 as "button_pressed"
[00e] 12547 DEFINESOUND defines id 0005 (MP3 11Khz 16Bit mono)
[028] 5 NAMECHARACTER adds information to id 0005 "hi"
[038] 7 EXPORTASSETS
exports 0005 as "hi"
[020] 41 DEFINESHAPE3 defines id 0006
[028] 12 NAMECHARACTER adds information to id 0006 "play_idle"
[038] 14 EXPORTASSETS
exports 0006 as "play_idle"
[020] 41 DEFINESHAPE3 defines id 0007
[028] 13 NAMECHARACTER adds information to id 0007 "play_hover"
[038] 15 EXPORTASSETS
exports 0007 as "play_hover"
[020] 41 DEFINESHAPE3 defines id 0008
[028] 15 NAMECHARACTER adds information to id 0008 "play_pressed"
[038] 17 EXPORTASSETS
exports 0008 as "play_pressed"
[022] 75 DEFINEBUTTON2 defines id 0009
[028] 7 NAMECHARACTER adds information to id 0009 "play"
[038] 9 EXPORTASSETS
exports 0009 as "play"
[00c] 114 DOACTION
[01a] 15 PLACEOBJECT2 places id 0001 at depth 0001 name "container"
[01a] 24 PLACEOBJECT2 places id 0009 at depth 0002 name "play"
[001] 0 SHOWFRAME 1 (00:00:00,000)
[000] 0 END
The second column lists the uncompressed size of each data element. You see that the sound file is the bulk of the SWF (12547 bytes) and actually has an uncompressed size larger than the final SWF size (SWF files often have an overall compression applied, beyond the compression of any individual element); you can also see that the sound file is in 16bit, 11kHz MP3 format. This is apparently the default sound encoding quality for swfc; you may be able to decrease this value for your purposes, but you’ll have to see whether your particular SWF compiler lets you do this.
When you export to a .swf file using Flash, you can set both jpeg image quality (compression rate) and .mp3 compression. So your best results would be achieved by using uncompressed image files or high quality jpeg files and using uncompressed WAV audio and letting Flash compress to the desired filesize.
The final filesize will be up to you to decide how much image compression artifacts and audio quality you can live with. This is the tradeoff.
I would limit your jpeg quality to no lower than 70% and .mp3 compression can probably go as low as 64k, mono, 11kHz. Beyond that the audio quality will be noticably degraded. Depensing on the sound effect, you may want to use a higher quality. Lower bitrates start to sound odd and lower sample rates will limit the high frequencies. Take into account that most users will have poor quality computer speakers and you may consider using that type of speaker as well as good headphones to listen while you find the optimal settings.