added --mp3-bitrate parameter.
[swftools.git] / avi2swf / avi2swf.cc
index 71e2f7d..be11eba 100644 (file)
@@ -4,8 +4,20 @@
    Part of the swftools package.
    
    Copyright (c) 2001,2002,2003 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 <stdio.h>
 #include <stdlib.h>
@@ -59,6 +71,7 @@ static int flashversion = 6;
 static int keyframe_interval = -1;
 static int skip = 0;
 static float audio_adjust = 0;
+static int mp3_bitrate = 32;
 
 struct options_t options[] =
 {
@@ -66,6 +79,7 @@ struct options_t options[] =
  {"A","adjust"},
  {"o","output"},
  {"p","flip"},
+ {"m","mp3-bitrate"},
  {"q","quality"},
  {"s","scale"},
  {"S","skip"},
@@ -113,6 +127,10 @@ 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, "S")) {
        skip = atoi(val);
        return 1;
@@ -139,6 +157,7 @@ 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 <rate>\t Set the mp3 bitrate to encode audio with\n");
     printf("\t-d , --scale <val>\t Scale down to factor <val>. (in %, e.g. 100 = original size)\n");
     printf("\t-p , --flip\t\t Turn movie upside down\n");
     printf("\t-q , --quality <val>\t Set the quality to <val>. (0-100, 0=worst, 100=best, default:80)\n");
@@ -316,10 +335,12 @@ bool videoreader_avifile_eof(videoreader_t* v)
 void videoreader_avifile_close(videoreader_t* v)
 {
     videoreader_avifile_internal*i = (videoreader_avifile_internal*)v->internal;
-    ringbuffer_clear(&i->audio_buffer);
     if(verbose) {
        printf("videoreader_close()\n");fflush(stdout);
     }
+    if(i->do_audio) {
+       ringbuffer_clear(&i->audio_buffer);
+    }
 }
 void* videoreader_avifile_getinfo(videoreader_t* v, char* name)
 {
@@ -495,7 +516,7 @@ 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, "fixheader", "1");
     //v2swf_setparameter(&v2swf, "framerate", "15");
     v2swf_setparameter(&v2swf, "scale", ftoa(scale));