X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=avi2swf%2Favi2swf.cc;h=8905a32a9635030f4263a0ae956b1287c3f37963;hp=c63df799872c70d42552d903eae672abc3e6d566;hb=893e0c1a38524ceac66557aee146dc1a05c1ff01;hpb=f15fe2d281b70a736152debc7c3ee49d40e755ca diff --git a/avi2swf/avi2swf.cc b/avi2swf/avi2swf.cc index c63df79..8905a32 100644 --- a/avi2swf/avi2swf.cc +++ b/avi2swf/avi2swf.cc @@ -71,6 +71,8 @@ static int flashversion = 6; static int keyframe_interval = -1; static int skip = 0; static float audio_adjust = 0; +static int mp3_bitrate = 32; +static int samplerate = 11025; struct options_t options[] = { @@ -78,6 +80,8 @@ struct options_t options[] = {"A","adjust"}, {"o","output"}, {"p","flip"}, + {"m","mp3-bitrate"}, + {"r","mp3-samplerate"}, {"q","quality"}, {"s","scale"}, {"S","skip"}, @@ -125,6 +129,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; @@ -151,6 +174,8 @@ void args_callback_usage(char*name) 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-m , --mp3-bitrate (kbps)\t Set the mp3 bitrate to encode audio with\n"); + printf("\t-r , --mp3-samplerate (Hz)\t Set the mp3 samplerate to encode audio with (default: 11025)\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"); @@ -280,9 +305,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; @@ -509,7 +532,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));