aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-04-16 12:51:24 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-04-16 23:44:49 -0400
commitb1041f80489b3fe428ef586e6d631fda40bef80e (patch)
treea3286b69a171fd6b945fda9490a934e675a6db1d
parent6943fb47d3bd0bd46734cdd762ab2c4ee89b0a22 (diff)
downloadffmpeg-b1041f80489b3fe428ef586e6d631fda40bef80e.tar.gz
avconv: only set the "channels" option when it exists for the specified input format
This allows the user to specify an input channel layout without avconv aborting because the "channels" option was not found.
-rw-r--r--avconv.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/avconv.c b/avconv.c
index 347f80493d..48b4c6b70b 100644
--- a/avconv.c
+++ b/avconv.c
@@ -3627,8 +3627,16 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena
av_dict_set(&format_opts, "sample_rate", buf, 0);
}
if (o->nb_audio_channels) {
- snprintf(buf, sizeof(buf), "%d", o->audio_channels[o->nb_audio_channels - 1].u.i);
- av_dict_set(&format_opts, "channels", buf, 0);
+ /* because we set audio_channels based on both the "ac" and
+ * "channel_layout" options, we need to check that the specified
+ * demuxer actually has the "channels" option before setting it */
+ if (file_iformat && file_iformat->priv_class &&
+ av_opt_find(&file_iformat->priv_class, "channels", NULL, 0,
+ AV_OPT_SEARCH_FAKE_OBJ)) {
+ snprintf(buf, sizeof(buf), "%d",
+ o->audio_channels[o->nb_audio_channels - 1].u.i);
+ av_dict_set(&format_opts, "channels", buf, 0);
+ }
}
if (o->nb_frame_rates) {
av_dict_set(&format_opts, "framerate", o->frame_rates[o->nb_frame_rates - 1].u.str, 0);