X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=avi2swf%2Favi2swf.cc;h=c68fedbbca3e0566260f60ac8f8d04022df749f2;hp=82d70c660ff8311cf0e5cb0e11a33f65c2131fd6;hb=2c719855eac434f01d47ba0717d76de65939d74e;hpb=95c9749e83bf6b3222f5d1a7b880c6c32bd0914a diff --git a/avi2swf/avi2swf.cc b/avi2swf/avi2swf.cc index 82d70c6..c68fedb 100644 --- a/avi2swf/avi2swf.cc +++ b/avi2swf/avi2swf.cc @@ -48,6 +48,8 @@ static int skip = 0; static float audio_adjust = 0; static int mp3_bitrate = 32; static int samplerate = 11025; +static int numframes = 0; +static char* skipframes = 0; static struct options_t options[] = { {"h", "help"}, @@ -56,9 +58,11 @@ static struct options_t options[] = { {"n", "num"}, {"m", "mp3-bitrate"}, {"r", "mp3-samplerate"}, -{"d", "scale"}, +{"s", "scale"}, +{"S", "skipframes"}, {"p", "flip"}, {"q", "quality"}, +{"k", "keyframe"}, {"x", "extragood"}, {"T", "flashversion"}, {"V", "version"}, @@ -75,6 +79,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) @@ -87,6 +99,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; @@ -105,7 +121,7 @@ int args_callback_option(char*name,char*val) } else if(!strcmp(name, "m")) { mp3_bitrate = atoi(val); - return 0; + return 1; } else if(!strcmp(name, "r")) { samplerate = atoi(val); @@ -126,6 +142,10 @@ int args_callback_option(char*name,char*val) skip = atoi(val); return 1; } + else if(!strcmp(name, "C")) { + skipframes = strdup(val); + return 1; + } else if(!strcmp(name, "s")) { scale = atoi(val)/100.0; if(scale>1.0 || scale<=0) { @@ -150,11 +170,13 @@ 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("-d , --scale Scale down to factor . (in %, e.g. 100 = original size)\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("-s , --scale Scale down to factor . (in %, e.g. 100 = original size)\n"); + printf("-S , --skipframes Skip frames before starting the conversion.\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"); + printf("-k , --keyframe Set the number of intermediate frames between keyframes.\n"); printf("-x , --extragood Enable some *very* expensive compression strategies.\n"); printf("-T , --flashversion Set output flash version to .\n"); printf("-V , --version Print program version and exit\n"); @@ -214,11 +236,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; } @@ -229,15 +253,15 @@ 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); } @@ -251,6 +275,8 @@ int main (int argc,char ** argv) 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"); @@ -262,6 +288,8 @@ int main (int argc,char ** argv) v2swf_setparameter(&v2swf, "prescale", "1"); v2swf_setparameter(&v2swf, "flash_version", itoa(flashversion)); v2swf_setparameter(&v2swf, "keyframe_interval", itoa(keyframe_interval)); + if(skipframes) + v2swf_setparameter(&v2swf, "skipframes", skipframes); if(expensive) v2swf_setparameter(&v2swf, "motioncompensation", "1"); if(flip)