Part of the swftools package.
Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
- This file is distributed under the GPL, see file COPYING for details */
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <stdlib.h>
#include <stdio.h>
char * filename = 0;
char * outputname = "output.swf";
int verbose = 2;
+int stopframe0 = 0;
#define DEFINESOUND_MP3 1 //define sound uses mp3?- undefine for raw sound.
{"b","bitrate"},
{"C","cgi"},
{"V","version"},
+ {"S","stop"},
{0,0}
};
verbose ++;
return 0;
}
+ else if(!strcmp(name, "S")) {
+ stopframe0 = 1;
+ return 0;
+ }
else if(!strcmp(name, "C")) {
do_cgi = 1;
return 0;
samplerate = 44100;
else {
fprintf(stderr, "Invalid samplerate: %d\n", samplerate);
- fprintf(stderr, "Allowed values: 11025, 22050\n", samplerate);
+ fprintf(stderr, "Allowed values: 11025, 22050, 44100\n", samplerate);
exit(1);
}
return 1;
printf("\t-b , --bitrate bps\t\t Set mp3 bitrate (default: 32)\n");
printf("\t-o , --output filename\t\t set output filename (default: output.swf)\n");
printf("\t-C , --cgi\t\t\t For use as CGI- prepend http header, write to stdout\n");
+ printf("\t-S , --stop\t\t\t Stop the movie at frame 0\n");
+ printf("\t \t\t\t (For use with flashsound.js)\n");
printf("\t-V , --version\t\t\t Print program version and exit\n");
}
int args_callback_command(char*name,char*val)
processargs(argc, argv);
- blocksize = 576;
+ blocksize = (samplerate > 22050) ? 1152 : 576;
+
blockspersecond = (float)samplerate/blocksize;
framespersecond = blockspersecond;
samples = (U16*)wav2.data;
numsamples = wav2.size/2;
+ if(numsamples%blocksize != 0)
+ {
+ // apply padding, so that block is a multiple of blocksize
+ int numblocks = (numsamples+blocksize-1)/blocksize;
+ int numsamples2;
+ U16* samples2;
+ numsamples2 = numblocks * blocksize;
+ samples2 = malloc(sizeof(U16)*numsamples2);
+ memcpy(samples2, samples, numsamples*sizeof(U16));
+ memset(&samples2[numsamples], 0, sizeof(U16)*(numsamples2 - numsamples));
+ numsamples = numsamples2;
+ samples = samples2;
+ }
+
memset(&swf,0x00,sizeof(SWF));
swf.fileVersion = 5;
rgb.g = 0xff;
rgb.b = 0xff;
swf_SetRGB(tag,&rgb);
+
+ if(stopframe0) {
+ ActionTAG*action = 0;
+ tag = swf_InsertTag(tag, ST_DOACTION);
+ action = action_Stop(action);
+ action = action_End(action);
+ swf_ActionSet(tag, action);
+ swf_ActionFree(action);
+
+ tag = swf_InsertTag(tag, ST_SHOWFRAME);
+ }
swf_mp3_bitrate = bitrate;
swf_mp3_out_samplerate = samplerate;
#else
swf_SetU8(tag,(/*compression*/0<<4)|(/*rate*/3<<2)|(/*size*/1<<1)|/*mono*/0);
swf_SetU32(tag, numsamples); // 44100 -> 11025
- swf_SetBlock(tag, wav2.data, numsamples*2);
+ swf_SetBlock(tag, samples, numsamples*2);
#endif