[x264-devel] Add --input-fmt option to lavf input

Yasuhiro Ikeda git at videolan.org
Wed Jan 26 02:56:57 CET 2011


x264 | branch: master | Yasuhiro Ikeda <wipple625 at gmail.com> | Thu Jan 20 23:12:01 2011 +0900| [bb4182d8ea123666819d9547a7b5234d4da34a1b] | committer: Jason Garrett-Glaser

Add --input-fmt option to lavf input
Conforms to ffmpeg's `-f` option.
Use this when lavf fails to guess the input format.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=bb4182d8ea123666819d9547a7b5234d4da34a1b
---

 input/input.h |    1 +
 input/lavf.c  |    7 ++++++-
 x264.c        |    6 ++++++
 3 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/input/input.h b/input/input.h
index 1deff12..c8008a6 100644
--- a/input/input.h
+++ b/input/input.h
@@ -34,6 +34,7 @@
 typedef struct
 {
     char *index_file;
+    char *format;
     char *resolution;
     char *colorspace;
     int bit_depth;
diff --git a/input/lavf.c b/input/lavf.c
index fc1172c..2f26aa9 100644
--- a/input/lavf.c
+++ b/input/lavf.c
@@ -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 4d5114b..c0d7a0f 100644
--- 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;



More information about the x264-devel mailing list