X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=avi2swf%2Favi2swf.cc;h=945afd1031dca3e598023f760f07a7806a4c483d;hb=22f4b2fb5eab04dff324b61eeef8cb3f0c99dc69;hp=c63df799872c70d42552d903eae672abc3e6d566;hpb=f15fe2d281b70a736152debc7c3ee49d40e755ca;p=swftools.git diff --git a/avi2swf/avi2swf.cc b/avi2swf/avi2swf.cc index c63df79..945afd1 100644 --- a/avi2swf/avi2swf.cc +++ b/avi2swf/avi2swf.cc @@ -71,20 +71,23 @@ static int flashversion = 6; static int keyframe_interval = -1; static int skip = 0; static float audio_adjust = 0; - -struct options_t options[] = -{ - {"v","verbose"}, - {"A","adjust"}, - {"o","output"}, - {"p","flip"}, - {"q","quality"}, - {"s","scale"}, - {"S","skip"}, - {"x","extragood"}, - {"T","flashversion"}, - {"V","version"}, - {0,0} +static int mp3_bitrate = 32; +static int samplerate = 11025; + +static struct options_t options[] = { +{"h", "help"}, +{"o", "output"}, +{"A", "adjust"}, +{"n", "num"}, +{"m", "mp3-bitrate"}, +{"r", "mp3-samplerate"}, +{"d", "scale"}, +{"p", "flip"}, +{"q", "quality"}, +{"x", "extragood"}, +{"T", "flashversion"}, +{"V", "version"}, +{0,0} }; int args_callback_option(char*name,char*val) @@ -125,6 +128,25 @@ int args_callback_option(char*name,char*val) expensive = 1; return 0; } + else if(!strcmp(name, "m")) { + mp3_bitrate = atoi(val); + return 0; + } + else if(!strcmp(name, "r")) { + samplerate = atoi(val); + if(samplerate >= 11000 && samplerate <= 12000) + samplerate = 11025; + else if(samplerate >= 22000 && samplerate <= 23000) + samplerate = 22050; + else if(samplerate >= 44000 && samplerate <= 45000) + samplerate = 44100; + else { + fprintf(stderr, "Invalid samplerate: %d\n", samplerate); + fprintf(stderr, "Allowed values: 11025, 22050, 44100\n", samplerate); + exit(1); + } + return 1; + } else if(!strcmp(name, "S")) { skip = atoi(val); return 1; @@ -144,22 +166,24 @@ int args_callback_longoption(char*name,char*val) { return args_long2shortoption(options, name, val); } -void args_callback_usage(char*name) -{ - printf("\nUsage: %s file.avi\n", name); - printf("\t-h , --help\t\t Print help and exit\n"); - printf("\t-o , --output filename\t Specify output filename\n"); - printf("\t-A , --adjust seconds\t Audio adjust: Shift sound -seconds to the future or +seconds into the past.\n"); - printf("\t-n , --num frames\t Number of frames to encode\n"); - printf("\t-d , --scale \t Scale down to factor . (in %, e.g. 100 = original size)\n"); - printf("\t-p , --flip\t\t Turn movie upside down\n"); - printf("\t-q , --quality \t Set the quality to . (0-100, 0=worst, 100=best, default:80)\n"); - printf("\t-x , --extragood\t Enable some *very* expensive compression strategies. You may\n"); - printf("\t \t want to let this run overnight.\n"); - printf("\t-T , --flashversion \t Set output flash version to . Notice: H.263 compression will only be\n"); - printf("\t \t used for n >= 6.\n"); - printf("\t-V , --version\t\t Print program version and exit\n"); - exit(0); +void args_callback_usage(char *name) +{ + printf("\n"); + printf("Usage: %s file.avi [-o output.swf]\n", name); + printf("\n"); + printf("-h , --help Print help and exit\n"); + 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("-p , --flip Turn movie upside down\n"); + printf("-q , --quality Set the quality to . (0-100, 0=worst, 100=best, default:80)\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"); + printf("\n"); } int args_callback_command(char*name,char*val) { @@ -280,9 +304,7 @@ int videoreader_avifile_getimage(videoreader_t* v, void*buffer) img->ToYUV(); img->ToRGB(); if(img->Bpp() != 3) { - /* TODO: this doesn't work yet */ - if(verbose) printf("Can't handle Bpp %d, shutting down...\n", img->Bpp()); - return 0; + if(verbose) printf("Warning: converthing from bpp %d to bpp 3, this fails on older avifile versions...\n", img->Bpp()); BitmapInfo tmp(v->width, v->height, 24); img2 = new CImage(img, &tmp); img = img2; @@ -381,6 +403,12 @@ int videoreader_avifile_open(videoreader_t* v, char* filename) printf("Couldn't open video stream\n"); i->do_audio = 0; } +#ifdef NO_MP3 + if(i->do_audio) { + printf(stderr, "MP3 support has been disabled at compile time, not converting soundtrack"); + i->do_audio = 0; + } +#endif if(!i->do_video && !i->do_audio) { printf("File has neither audio nor video streams.(?)\n"); @@ -509,7 +537,8 @@ int main (int argc,char ** argv) v2swf_setparameter(&v2swf, "quality", itoa(quality)); v2swf_setparameter(&v2swf, "blockdiff", "0"); v2swf_setparameter(&v2swf, "blockdiff_mode", "exact"); - v2swf_setparameter(&v2swf, "mp3_bitrate", "32"); + v2swf_setparameter(&v2swf, "mp3_bitrate", itoa(mp3_bitrate)); + v2swf_setparameter(&v2swf, "samplerate", itoa(samplerate)); //v2swf_setparameter(&v2swf, "fixheader", "1"); //v2swf_setparameter(&v2swf, "framerate", "15"); v2swf_setparameter(&v2swf, "scale", ftoa(scale));