[xiph-commits] r10367 - trunk/ffmpeg2theora

j at svn.xiph.org j at svn.xiph.org
Sun Nov 13 10:15:42 PST 2005


Author: j
Date: 2005-11-13 10:15:30 -0800 (Sun, 13 Nov 2005)
New Revision: 10367

Modified:
   trunk/ffmpeg2theora/ChangeLog
   trunk/ffmpeg2theora/ffmpeg2theora.1
   trunk/ffmpeg2theora/ffmpeg2theora.c
Log:
thanks Fabio Pedretti for the patch.

* removed the V2V_PRESET_DEFAULT and made the default use 
  the same video resolution as the input file. 
  Also this solves a problem: before the V2V_PRESET_DEFAULT 
  was used only when argc==2, so when I use some options that 
  sholdn't change quality like "-o newfile.ogg", 
  argc was 3 and didn't use the preset.
* change the audio quality levels that were multiplied by 0.99, 
  now match the quality settings of oggenc, e.g. -a2 == -q2.
* some minor cleanup
* update to help and manpage



Modified: trunk/ffmpeg2theora/ChangeLog
===================================================================
--- trunk/ffmpeg2theora/ChangeLog	2005-11-12 20:39:01 UTC (rev 10366)
+++ trunk/ffmpeg2theora/ChangeLog	2005-11-13 18:15:30 UTC (rev 10367)
@@ -1,7 +1,16 @@
+svn
+    - support encoding from .ogg input file.
+    - don't change samplerate and audio channel unless we use command line
+      options.
+    - don't change the resolution image, unless we use the presets or the
+      -x or -y options. (old default was to encode to preset preview)
+    - change the audio quality levels that were multiplied by 0.99, now 
+      match the quality settings of oggenc, e.g. -a2 == -q2.
+
 0.15     2005-08-31
     - ti.dropframes_p = 0 so we do not loos half of the frames.
     - also increase keyframe interval for better search support.
-    - this time the windows build als supports ac3 decoding again.
+    - this time the windows build also supports ac3 decoding again.
 
 0.14     2005-08-15
     - add support for v4l input devices

Modified: trunk/ffmpeg2theora/ffmpeg2theora.1
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.1	2005-11-12 20:39:01 UTC (rev 10366)
+++ trunk/ffmpeg2theora/ffmpeg2theora.1	2005-11-13 18:15:30 UTC (rev 10367)
@@ -20,8 +20,8 @@
 .SH DESCRIPTION
 This manual page documents briefly the \fBffmpeg2theora\fP command.
 .PP
-\fBffmpeg2theora\fP is a program that converts any video file that ffmpeg can
-decode to Ogg Theora.
+\fBffmpeg2theora\fP is a program that converts any media file that ffmpeg can
+decode to Ogg Theora for video and Ogg Vorbis for audio.
 .SH OPTIONS
 To read from standard input, specify `\-' as the input filename.
 
@@ -35,6 +35,12 @@
 be written to \fIinputfile\fP.ogg.  To output to standard output, specify
 /dev/stdout as the output file.
 .TP
+.B \-v, \-\-videoquality
+[0 to 10] Set encoding quality for video (default: 5).
+.TP
+.B \-V, \-\-videobitrate
+[45 to 2000] Set encoding bitrate for video.
+.TP
 .B \-x, \-\-width
 Scale to given width.
 .TP
@@ -47,21 +53,15 @@
 .B \-\-crop[top|bottom|left|right]
 Crop input before resizing.
 .TP
-.B \-v, \-\-videoquality
-[0 to 10] Set encoding quality for video.
-.TP
-.B \-V, \-\-videobitrate
-[45 to 2000] Set encoding bitrate for video.
-.TP
 .B \-S, \-\-sharpness
-[0 to 2] Sharpness of images (default 2).  Note: lower values make the video
+[0 to 2] Sharpness of images (default: 2).  Note: lower values make the video
 sharper.
 .TP
 .B \-K, \-\-keyint
-[8 to 65536] Set keyframe interval (default 64).
+[8 to 65536] Set keyframe interval (default: 64).
 .TP
 .B \-a, \-\-audioquality
-[-1 to 10] Set encoding quality for audio.
+[-1 to 10] Set encoding quality for audio (default: 1).
 .TP
 .B \-A, \-\-audiobitrate
 [45 to 2000] Set encoding bitrate for audio.

Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c	2005-11-12 20:39:01 UTC (rev 10366)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c	2005-11-13 18:15:30 UTC (rev 10367)
@@ -50,13 +50,19 @@
 #define INPUTFPS_FLAG       11
 #define AUDIOSTREAM_FLAG    12
 
-
-
 #define V2V_PRESET_PRO 1
 #define V2V_PRESET_PREVIEW 2
-#define V2V_PRESET_DEFAULT 3
 
+#define PAL_HALF_WIDTH 384
+#define PAL_HALF_HEIGHT 288
+#define NTSC_HALF_WIDTH 320
+#define NTSC_HALF_HEIGHT 240
 
+#define PAL_FULL_WIDTH 720
+#define PAL_FULL_HEIGHT 576
+#define NTSC_FULL_WIDTH 720
+#define NTSC_FULL_HEIGHT 480
+
 typedef struct ff2theora{
     AVFormatContext *context;
     int video_index;
@@ -160,7 +166,7 @@
         // audio
         this->sample_rate = -1;  // samplerate hmhmhm
         this->channels = -1;
-        this->audio_quality=1*.099;// audio quality 1
+        this->audio_quality = 1.00;// audio quality 1
         this->audio_bitrate=0;
         this->audiostream = -1;
         
@@ -240,45 +246,25 @@
             this->video_index = -1;
 
         this->fps = fps;
-        
-        if(this->preset == V2V_PRESET_DEFAULT){
-            // possible sizes 384/288,320/240
-            int pal_width=384;
-            int pal_height=288;
-            int ntsc_width=320;
-            int ntsc_height=240;
-            if(this->fps==25 && (venc->width>pal_width && venc->height>pal_height) ){
-                this->picture_width=pal_width;
-                this->picture_height=pal_height;
+
+        if(this->preset == V2V_PRESET_PREVIEW){
+            if(this->fps==25 && (venc->width!=PAL_HALF_WIDTH || venc->height!=PAL_HALF_HEIGHT) ){
+                this->picture_width=PAL_HALF_WIDTH;
+                this->picture_height=PAL_HALF_HEIGHT;
             }
-            else if(abs(this->fps-30)<1 && (venc->width>ntsc_width && venc->height>ntsc_height) ){
-                this->picture_width=ntsc_width;
-                this->picture_height=ntsc_height;
+            else if(abs(this->fps-30)<1 && (venc->width!=NTSC_HALF_WIDTH || venc->height!=NTSC_HALF_HEIGHT) ){
+                this->picture_width=NTSC_HALF_WIDTH;
+                this->picture_height=NTSC_HALF_HEIGHT;
             }
         }
-        else if(this->preset == V2V_PRESET_PREVIEW){
-            // possible sizes 384/288,320/240
-            int pal_width=384;
-            int pal_height=288;
-            int ntsc_width=320;
-            int ntsc_height=240;
-            if(this->fps==25 && (venc->width!=pal_width || venc->height!=pal_height) ){
-                this->picture_width=pal_width;
-                this->picture_height=pal_height;
-            }
-            else if(abs(this->fps-30)<1 && (venc->width!=ntsc_width || venc->height!=ntsc_height) ){
-                this->picture_width=ntsc_width;
-                this->picture_height=ntsc_height;
-            }
-        }
         else if(this->preset == V2V_PRESET_PRO){
-            if(this->fps==25 && (venc->width!=720 || venc->height!=576) ){
-                this->picture_width=720;
-                this->picture_height=576;
+            if(this->fps==25 && (venc->width!=PAL_FULL_WIDTH || venc->height!=PAL_FULL_HEIGHT) ){
+                this->picture_width=PAL_FULL_WIDTH;
+                this->picture_height=PAL_FULL_HEIGHT;
             }
-            else if(abs(this->fps-30)<1 && (venc->width!=720 || venc->height!=480) ){
-                this->picture_width=720;
-                this->picture_height=480;
+            else if(abs(this->fps-30)<1 && (venc->width!=NTSC_FULL_WIDTH || venc->height!=NTSC_FULL_HEIGHT) ){
+                this->picture_width=NTSC_FULL_WIDTH;
+                this->picture_height=NTSC_FULL_HEIGHT;
             }
         }
         if (this->deinterlace==1)
@@ -333,13 +319,11 @@
             fprintf(stderr,"  Frame Aspect Ratio: %.2f/1\n",frame_aspect);
         }
 
-        
-        /* Theora has a divisible-by-sixteen restriction for the encoded video size */  /* scale the frame size up to the nearest /16 and calculate offsets */
-
         if(!this->picture_width) 
             this->picture_width = venc->width;
         if(!this->picture_height)
             this->picture_height = venc->height;
+
         /* Theora has a divisible-by-sixteen restriction for the encoded video size */
         /* scale the frame size up to the nearest /16 and calculate offsets */
         this->frame_width = ((this->picture_width + 15) >>4)<<4;
@@ -451,9 +435,7 @@
                             this->frame_width, this->frame_height);
             output_buffered =alloc_picture(PIX_FMT_YUV420P,
                             this->frame_width, this->frame_height);    
-        }
 
-        if(!info.audio_only){
             /* video settings here */
             /* config file? commandline options? v2v presets? */
             
@@ -503,7 +485,7 @@
         /* audio settings here */
         info.channels = this->channels;
         info.sample_rate = this->sample_rate;
-        info.vorbis_quality = this->audio_quality;
+        info.vorbis_quality = this->audio_quality * 0.1;
         info.vorbis_bitrate = this->audio_bitrate;
         oggmux_init (&info);
         /*seek to start time*/
@@ -766,17 +748,19 @@
         " usage: " PACKAGE " [options] input\n\n"
     
         "Output options:\n"
-        "\t --output,-o\t\talternative output\n"
+        "\t --output,-o\t\talternative output filename\n"
+        "\t --videoquality,-v\t[0 to 10] encoding quality for video\n"
+        "\t                 \t (default: 5)\n"
+        "\t --videobitrate,-V\t[45 to 2000] encoding bitrate for video\n"
         "\t --width, -x\t\tscale to given size\n"
         "\t --height,-y\t\tscale to given size\n"
         "\t --aspect\t\tdefine frame aspect ratio: i.e. 4:3 or 16:9\n"
         "\t --crop[top|bottom|left|right]\tcrop input before resizing\n"        
-        "\t --videoquality,-v\t[0 to 10]    encoding quality for video\n"
-        "\t --videobitrate,-V\t[45 to 2000] encoding bitrate for video\n"
-        "\t --sharpness,-S  \t[0 to 2]     sharpness of images(default 2)\n"
-        "\t                 \t   { lower values make the video sharper. }\n"
+        "\t --sharpness,-S  \t[0 to 2] sharpness of images (default: 2)\n"
+        "\t                 \t { lower values make the video sharper. }\n"
         "\t --keyint,-K      \t[8 to 65536] keyframe interval (default: 64)\n"
-        "\t --audioquality,-a\t[-1 to 10]   encoding quality for audio\n"
+        "\t --audioquality,-a\t[-1 to 10] encoding quality for audio\n"
+        "\t                 \t (default: 1)\n"
         "\t --audiobitrate,-A\t[45 to 2000] encoding bitrate for audio\n"
         "\t --samplerate,-H\tset output samplerate in Hz\n"
         "\t --channels,-c\t\tset number of output sound channels\n"
@@ -1020,8 +1004,8 @@
                 convert->video_quality=0;
                 break; 
             case 'a':
-                convert->audio_quality=atof(optarg)*.099;
-                if(convert->audio_quality<-.2 || convert->audio_quality>1){
+                convert->audio_quality=atof(optarg);
+                if(convert->audio_quality<-2 || convert->audio_quality>10){
                     fprintf(stderr,"only values from -1 to 10 are valid for audio quality\n");
                     exit(1);
                 }
@@ -1033,7 +1017,7 @@
                     fprintf(stderr,"only values >0 are valid for audio bitrate\n");
                     exit(1);
                 }
-                convert->audio_quality=-99;
+                convert->audio_quality=-990;
                 break;
             case 'S':
                 convert->sharpness = atoi(optarg);
@@ -1066,7 +1050,7 @@
                     //need a way to set resize here. and not later
                     convert->preset=V2V_PRESET_PRO;
                     convert->video_quality = rint(7*6.3);
-                    convert->audio_quality=3*.099;
+                    convert->audio_quality = 3.00;
                     convert->channels=2;
                     convert->sample_rate=48000;
                     convert->sharpness=0;
@@ -1075,7 +1059,7 @@
                     //need a way to set resize here. and not later
                     convert->preset=V2V_PRESET_PREVIEW;
                     convert->video_quality = rint(5*6.3);
-                    convert->audio_quality=1*.099;
+                    convert->audio_quality = 1.00;
                     convert->channels=2;
                     convert->sample_rate=44100;
                     convert->sharpness=2;
@@ -1101,19 +1085,6 @@
                 exit(1);
         }  
     }    
-    //use PREVIEW quality settings, but do not upsample audio/video
-    if(argc==2){
-        //need a way to set resize here. and not later
-        convert->preset=V2V_PRESET_DEFAULT;
-
-// this should not be changed from default if no arguments are given
-/*
-        convert->video_quality = rint(5*6.3);
-        convert->audio_quality=1*.099;
-        convert->channels=2;
-        convert->sample_rate=44100;
-*/
-    }
     
     while(optind<argc){
         /* assume that anything following the options must be a filename */
@@ -1140,8 +1111,8 @@
 
     if(formatParams != NULL) {
         formatParams->channel = 0;
-        formatParams->width = 384;
-        formatParams->height = 288;
+        formatParams->width = PAL_HALF_WIDTH;
+        formatParams->height = PAL_HALF_HEIGHT;
         if(convert->picture_width)
             formatParams->width = convert->picture_width;
         if(convert->picture_height)



More information about the commits mailing list