]> granicus.if.org Git - libx264/commitdiff
new option: --fps
authorLoren Merritt <pengvado@videolan.org>
Wed, 29 Dec 2004 12:08:50 +0000 (12:08 +0000)
committerLoren Merritt <pengvado@videolan.org>
Wed, 29 Dec 2004 12:08:50 +0000 (12:08 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@75 df754926-b1dd-0310-bc7b-ec298dee348c

x264.c

diff --git a/x264.c b/x264.c
index 7ab863e52205a1ecde20a22e1ae99ec37b1f2488..0dc8f9873ac740bbb3da6aacacf11ad849449fb1 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -138,6 +138,7 @@ static void Help( void )
              "      --subme <integer>       Subpixel motion estimation quality\n"
              "\n"
              "  -s, --sar width:height      Specify Sample Aspect Ratio\n"
+             "      --fps <float|rational>  Specify framerate\n"
              "      --frames <integer>      Maximum number of frames to encode\n"
              "  -o, --output                Specify output file\n"
              "\n"
@@ -186,6 +187,7 @@ static int  Parse( int argc, char **argv,
 #define OPT_QBLUR 271
 #define OPT_CPLXBLUR 272
 #define OPT_FRAMES 273
+#define OPT_FPS 274
 
         static struct option long_options[] =
         {
@@ -205,6 +207,7 @@ static int  Parse( int argc, char **argv,
             { "ref",     required_argument, NULL, 'r' },
             { "no-asm",  no_argument,       NULL, 'C' },
             { "sar",     required_argument, NULL, 's' },
+            { "fps",     required_argument, NULL, OPT_FPS },
             { "frames",  required_argument, NULL, OPT_FRAMES },
             { "output",  required_argument, NULL, 'o' },
             { "analyse", required_argument, NULL, 'A' },
@@ -316,6 +319,22 @@ static int  Parse( int argc, char **argv,
                 }
                 break;
             }
+            case OPT_FPS:
+            {
+                float fps;
+                if( sscanf( optarg, "%d/%d", &param->i_fps_num, &param->i_fps_den ) == 2 )
+                    ;
+                else if( sscanf( optarg, "%f", &fps ) )
+                {
+                    param->i_fps_num = (int)(fps * 1000 + .5);
+                    param->i_fps_den = 1000;
+                }
+                else
+                {
+                    fprintf( stderr, "bad fps `%s'\n", optarg );
+                    return -1;
+                }
+            }
             case 'A':
                 param->analyse.inter = 0;
                 if( strstr( optarg, "none" ) )  param->analyse.inter = 0x000000;
@@ -677,7 +696,7 @@ static int  Encode( x264_param_t  *param, FILE *fyuv, FILE *fout )
         double fps = (double)i_frame * (double)1000000 /
                      (double)( i_end - i_start );
 
-        fprintf( stderr, "encoded %d frames %ffps %lld kb/s\n", i_frame, fps, i_file * 8 * 25 / i_frame / 1000 );
+        fprintf( stderr, "encoded %d frames, %.2f fps, %.2f kb/s\n", i_frame, fps, (double) i_file * 8 * param->i_fps_num / ( param->i_fps_den * i_frame * 1000 ) );
     }
 
     return 0;