]> git.sesse.net Git - x264/commitdiff
Add --input-fmt option to lavf input
authorYasuhiro Ikeda <wipple625@gmail.com>
Thu, 20 Jan 2011 14:12:01 +0000 (23:12 +0900)
committerFiona Glaser <fiona@x264.com>
Tue, 25 Jan 2011 20:16:31 +0000 (12:16 -0800)
Conforms to ffmpeg's `-f` option.
Use this when lavf fails to guess the input format.

input/input.h
input/lavf.c
x264.c

index 1deff127a51a2f57ccb5e4eeb01d0ee4405f2a94..c8008a6a1f94d4e0cda44a98710f05b18d268cf8 100644 (file)
@@ -34,6 +34,7 @@
 typedef struct
 {
     char *index_file;
+    char *format;
     char *resolution;
     char *colorspace;
     int bit_depth;
index fc1172c312442ce2e36126dc0fff482ab07bf14b..2f26aa9e9eaa45774f3b5f253df58b27d309fd62 100644 (file)
@@ -147,7 +147,12 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
         param->pix_fmt = opt->colorspace ? av_get_pix_fmt( opt->colorspace ) : PIX_FMT_YUV420P;
     }
 
-    FAIL_IF_ERROR( av_open_input_file( &h->lavf, psz_filename, NULL, 0, param ), "could not open input file\n" )
+    /* specify the input format. this is helpful when lavf fails to guess */
+    AVInputFormat *format = NULL;
+    if( opt->format )
+        FAIL_IF_ERROR( !(format = av_find_input_format( opt->format )), "unknown file format: %s\n", opt->format );
+
+    FAIL_IF_ERROR( av_open_input_file( &h->lavf, psz_filename, format, 0, param ), "could not open input file\n" )
     if( param )
         free( param );
     FAIL_IF_ERROR( av_find_stream_info( h->lavf ) < 0, "could not find input stream info\n" )
diff --git a/x264.c b/x264.c
index 00faf93caa8dc6b12dde288ef8118706ad3b83e0..96a0a0227147a51bc6ecb77e172b46a87fb5614a 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -721,6 +721,7 @@ static void help( x264_param_t *defaults, int longhelp )
         "                                  - %s\n", muxer_names[0], stringify_names( buf, muxer_names ) );
     H1( "      --demuxer <string>      Specify input container format [\"%s\"]\n"
         "                                  - %s\n", demuxer_names[0], stringify_names( buf, demuxer_names ) );
+    H1( "      --input-fmt <string>    Specify input file format (requires lavf support)\n" );
     H1( "      --input-csp <string>    Specify input colorspace format for raw input\n" );
     print_csp_names( longhelp );
     H1( "      --input-depth <integer> Specify input bit depth for raw input\n" );
@@ -797,6 +798,7 @@ enum
     OPT_PULLDOWN,
     OPT_LOG_LEVEL,
     OPT_VIDEO_FILTER,
+    OPT_INPUT_FMT,
     OPT_INPUT_RES,
     OPT_INPUT_CSP,
     OPT_INPUT_DEPTH,
@@ -952,6 +954,7 @@ static struct option long_options[] =
     { "frame-packing",     required_argument, NULL, 0 },
     { "vf",          required_argument, NULL, OPT_VIDEO_FILTER },
     { "video-filter", required_argument, NULL, OPT_VIDEO_FILTER },
+    { "input-fmt",   required_argument, NULL, OPT_INPUT_FMT },
     { "input-res",   required_argument, NULL, OPT_INPUT_RES },
     { "input-csp",   required_argument, NULL, OPT_INPUT_CSP },
     { "input-depth", required_argument, NULL, OPT_INPUT_DEPTH },
@@ -1314,6 +1317,9 @@ static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )
             case OPT_VIDEO_FILTER:
                 vid_filters = optarg;
                 break;
+            case OPT_INPUT_FMT:
+                input_opt.format = optarg;
+                break;
             case OPT_INPUT_RES:
                 input_opt.resolution = optarg;
                 break;