X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=avi2swf%2Favi2swf.cc;h=a9e4619fe4230848be5657326d831ffe38fcf553;hb=c5632476384129c77fab3dea934358ac6e7e4418;hp=dc9f5fee40329e2c2675720d1296930428ca1eac;hpb=27cad6e7823431d7ca07e92df74d063da5401f34;p=swftools.git diff --git a/avi2swf/avi2swf.cc b/avi2swf/avi2swf.cc index dc9f5fe..a9e4619 100644 --- a/avi2swf/avi2swf.cc +++ b/avi2swf/avi2swf.cc @@ -28,7 +28,11 @@ #include "../lib/args.h" #include "v2swf.h" +#ifdef WIN32 +#include "videoreader_vfw.hh" +#else #include "videoreader_avifile.hh" +#endif static char * filename = 0; static char * outputfilename = "output.swf"; @@ -44,6 +48,7 @@ static int skip = 0; static float audio_adjust = 0; static int mp3_bitrate = 32; static int samplerate = 11025; +static int numframes = 0; static struct options_t options[] = { {"h", "help"}, @@ -53,6 +58,7 @@ static struct options_t options[] = { {"m", "mp3-bitrate"}, {"r", "mp3-samplerate"}, {"d", "scale"}, +{"k", "keyframe"}, {"p", "flip"}, {"q", "quality"}, {"x", "extragood"}, @@ -71,6 +77,14 @@ int args_callback_option(char*name,char*val) outputfilename = val; return 1; } + else if(!strcmp(name, "n")) { + numframes = atoi(val); + return 1; + } + else if(!strcmp(name, "d")) { + scale = atof(val); + return 1; + } else if(!strcmp(name, "q")) { quality = atoi(val); if(quality<0) @@ -83,6 +97,10 @@ int args_callback_option(char*name,char*val) flip = 1; return 0; } + else if(!strcmp(name, "k")) { + keyframe_interval = atoi(val); + return 1; + } else if(!strcmp(name, "A")) { audio_adjust = atof(val); return 1; @@ -146,8 +164,8 @@ void args_callback_usage(char *name) printf("-o , --output filename Specify output filename\n"); printf("-A , --adjust seconds Audio adjust: Shift sound -seconds to the future or +seconds into the past.\n"); printf("-n , --num frames Number of frames to encode\n"); - printf("-m , --mp3-bitrate (kbps) Set the mp3 bitrate to encode audio with\n"); - printf("-r , --mp3-samplerate (Hz) Set the mp3 samplerate to encode audio with (default: 11025)\n"); + printf("-m , --mp3-bitrate Set the mp3 bitrate to encode audio with\n"); + printf("-r , --mp3-samplerate Set the mp3 samplerate to encode audio with (default: 11025)\n"); printf("-d , --scale Scale down to factor . (in %, e.g. 100 = original size)\n"); printf("-p , --flip Turn movie upside down\n"); printf("-q , --quality Set the quality to . (0-100, 0=worst, 100=best, default:80)\n"); @@ -210,11 +228,13 @@ int main (int argc,char ** argv) #endif processargs(argc, argv); - if(!filename) + if(!filename) { + fprintf(stderr, "You must supply a filename"); exit(0); + } if(keyframe_interval<0) { if(flashversion>=6) - keyframe_interval=200; + keyframe_interval=20; else keyframe_interval=5; } @@ -225,24 +245,30 @@ int main (int argc,char ** argv) fprintf(stderr, "Couldn't open %s\n", outputfilename); exit(1); } - + +#ifdef WIN32 + ret = videoreader_vfw_open(&video, filename); +#else ret = videoreader_avifile_open(&video, filename); +#endif - if(!ret) { - printf("Error opening %s\n", filename); + if(ret<0) { + fprintf(stderr, "Error opening %s\n", filename); exit(1); } if(verbose) { printf("| video framerate: %f\n", video.fps); printf("| video size: %dx%d\n", video.width, video.height); - printf("| audio rate: %d\n", video.rate); + printf("| audio rate: %d\n", video.samplerate); printf("| audio channels: %d\n", video.channels); } ret = v2swf_init(&v2swf, &video); if(verbose) v2swf_setparameter(&v2swf, "verbose", "1"); + if(numframes) + v2swf_setparameter(&v2swf, "numframes", itoa(numframes)); v2swf_setparameter(&v2swf, "quality", itoa(quality)); v2swf_setparameter(&v2swf, "blockdiff", "0"); v2swf_setparameter(&v2swf, "blockdiff_mode", "exact"); @@ -265,7 +291,7 @@ int main (int argc,char ** argv) printf("\n"); if(audio_adjust>0) { - int num = ((int)(audio_adjust*video.rate))*video.channels*2; + int num = ((int)(audio_adjust*video.samplerate))*video.channels*2; void*buf = malloc(num); video.getsamples(&video, buf, num); free(buf); @@ -284,7 +310,7 @@ int main (int argc,char ** argv) void*buf = malloc(video.width*video.height*4); for(t=0;t