This allows the user to use channel layout names instead of having to use the
channel mask values.
---
avconv.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/avconv.c b/avconv.c
index 2dce66f..9a914a5 100644
--- a/avconv.c
+++ b/avconv.c
@@ -4377,6 +4377,39 @@ static void parse_cpuflags(int argc, char **argv, const
OptionDef *options)
opt_cpuflags("cpuflags", argv[idx + 1]);
}
+static int opt_channel_layout(OptionsContext *o, const char *opt, const char
*arg)
+{
+ char layout_str[32];
+ char *stream_str;
+ char *ac_str;
+ int channels, ac_str_size;
+ uint64_t layout;
+
+ layout = av_get_channel_layout(arg);
+ if (!layout) {
+ av_log(NULL, AV_LOG_ERROR, "Unknown channel layout: %s\n", arg);
+ return AVERROR(EINVAL);
+ }
+ snprintf(layout_str, sizeof(layout_str), "%"PRIu64, layout);
+ opt_default(opt, layout_str);
+
+ /* set 'ac' option based on channel layout */
+ channels = av_get_channel_layout_nb_channels(layout);
+ snprintf(layout_str, sizeof(layout_str), "%d", channels);
+ stream_str = strchr(opt, ':');
+ ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
+ ac_str = av_mallocz(ac_str_size);
+ if (!ac_str)
+ return AVERROR(ENOMEM);
+ av_strlcpy(ac_str, "ac", 3);
+ if (stream_str)
+ av_strlcat(ac_str, stream_str, ac_str_size);
+ parse_option(o, ac_str, layout_str, options);
+ av_free(ac_str);
+
+ return 0;
+}
+
#define OFFSET(x) offsetof(OptionsContext, x)
static const OptionDef options[] = {
/* main options */
@@ -4465,6 +4498,7 @@ static const OptionDef options[] = {
{ "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2,
{(void*)opt_audio_tag}, "force audio tag/fourcc", "fourcc/tag" },
{ "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change
audio volume (256=normal)" , "volume" }, //
{ "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_SPEC | OPT_STRING,
{.off = OFFSET(sample_fmts)}, "set sample format", "format" },
+ { "channel_layout", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2,
{(void*)opt_channel_layout}, "set channel layout", "layout" },
/* subtitle options */
{ "sn", OPT_BOOL | OPT_SUBTITLE | OPT_OFFSET, {.off =
OFFSET(subtitle_disable)}, "disable subtitle" },
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel