[FFmpeg-devel] [PATCH] ffmpeg: add -guess_layout_max option.

Nicolas George nicolas.george at normalesup.org
Mon Dec 31 16:35:37 CET 2012


Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
 doc/ffmpeg.texi |    6 ++++++
 ffmpeg.c        |    2 ++
 ffmpeg.h        |    1 +
 ffmpeg_opt.c    |    3 +++
 4 files changed, 12 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index d0fe327..7ccfc5c 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -595,6 +595,12 @@ also sources and sinks).  This is an alias for @code{-filter:a}.
 Force audio tag/fourcc. This is an alias for @code{-tag:a}.
 @item -absf @var{bitstream_filter}
 Deprecated, see -bsf
+ at item -guess_layout_max @var{channels} (@emph{input})
+If some input channel layout is not known, try to guess only if it
+corresponds to at most the specified number of channels. For example, 2
+tells to @command{ffmpeg} to recognize 1 channel as mono and 2 channels as
+stereo but not 6 channels as 5.1. The default is to always try to guess. Use
+0 to disable all guessing.
 @end table
 
 @section Subtitle options:
diff --git a/ffmpeg.c b/ffmpeg.c
index 977218f..de6e66c 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1441,6 +1441,8 @@ int guess_input_channel_layout(InputStream *ist)
     if (!dec->channel_layout) {
         char layout_name[256];
 
+        if (dec->channels > guess_layout_max)
+            return 0;
         dec->channel_layout = av_get_default_channel_layout(dec->channels);
         if (!dec->channel_layout)
             return 0;
diff --git a/ffmpeg.h b/ffmpeg.h
index 1260563..9864eac 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -385,6 +385,7 @@ extern int copy_ts;
 extern int copy_tb;
 extern int debug_ts;
 extern int exit_on_error;
+extern int guess_layout_max;
 extern int print_stats;
 extern int qp_hist;
 extern int stdin_interaction;
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index fcd6048..7c25912 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -81,6 +81,7 @@ int copy_ts           = 0;
 int copy_tb           = -1;
 int debug_ts          = 0;
 int exit_on_error     = 0;
+int guess_layout_max  = INT_MAX;
 int print_stats       = 1;
 int qp_hist           = 0;
 int stdin_interaction = 1;
@@ -2581,6 +2582,8 @@ const OptionDef options[] = {
         "set channel layout", "layout" },
     { "af",             OPT_AUDIO | HAS_ARG  | OPT_PERFILE,                        { .func_arg = opt_audio_filters },
         "audio filters", "filter list" },
+    { "guess_layout_max", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_EXPERT,              { &guess_layout_max },
+      "maximum number of channels to try to guess the channel layout" },
 
     /* subtitle options */
     { "sn",     OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET, { .off = OFFSET(subtitle_disable) },
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list