---
 avconv.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/avconv.c b/avconv.c
index 91613d4..920b184 100644
--- a/avconv.c
+++ b/avconv.c
@@ -124,7 +124,6 @@ static char *vfilters = NULL;
 static int audio_sample_rate = 0;
 #define QSCALE_NONE -99999
 static float audio_qscale = QSCALE_NONE;
-static int audio_channels = 0;
 
 static int file_overwrite = 0;
 static int do_benchmark = 0;
@@ -279,6 +278,8 @@ typedef struct OptionsContext {
 
     SpecifierOpt *codec_names;
     int        nb_codec_names;
+    SpecifierOpt *audio_channels;
+    int        nb_audio_channels;
 
     /* input options */
     int64_t input_ts_offset;
@@ -2593,12 +2594,6 @@ static int opt_audio_rate(const char *opt, const char 
*arg)
     return 0;
 }
 
-static int opt_audio_channels(const char *opt, const char *arg)
-{
-    audio_channels = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
-    return 0;
-}
-
 static int opt_audio_codec(OptionsContext *o, const char *opt, const char *arg)
 {
     return parse_option(o, "codec:a", arg, options);
@@ -2899,8 +2894,8 @@ static int opt_input_file(OptionsContext *o, const char 
*opt, const char *filena
         snprintf(buf, sizeof(buf), "%d", audio_sample_rate);
         av_dict_set(&format_opts, "sample_rate", buf, 0);
     }
-    if (audio_channels) {
-        snprintf(buf, sizeof(buf), "%d", audio_channels);
+    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);
     }
     if (frame_rate.num) {
@@ -2973,7 +2968,6 @@ static int opt_input_file(OptionsContext *o, const char 
*opt, const char *filena
     frame_height = 0;
     frame_width  = 0;
     audio_sample_rate = 0;
-    audio_channels    = 0;
 
     for (i = 0; i < orig_nb_streams; i++)
         av_dict_free(&opts[i]);
@@ -3189,8 +3183,8 @@ static OutputStream *new_audio_stream(OptionsContext *o, 
AVFormatContext *oc)
             audio_enc->flags |= CODEC_FLAG_QSCALE;
             audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;
         }
-        if (audio_channels)
-            audio_enc->channels = audio_channels;
+
+        MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->audio_channels, oc, 
st);
 
         MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st);
         if (sample_fmt &&
@@ -3629,7 +3623,6 @@ static void opt_output_file(void *optctx, const char 
*filename)
     frame_width   = 0;
     frame_height  = 0;
     audio_sample_rate = 0;
-    audio_channels    = 0;
 
     av_freep(&streamid_map);
     nb_streamid_map = 0;
@@ -3860,7 +3853,7 @@ static int opt_target(OptionsContext *o, const char *opt, 
const char *arg)
 
         opt_default("b:a", "224000");
         audio_sample_rate = 44100;
-        audio_channels = 2;
+        parse_option(o, "ac", "2", options);
 
         opt_default("packetsize", "2324");
         opt_default("muxrate", "1411200"); // 2352 * 75 * 8;
@@ -3924,7 +3917,7 @@ static int opt_target(OptionsContext *o, const char *opt, 
const char *arg)
         opt_frame_rate("r", frame_rates[norm]);
 
         audio_sample_rate = 48000;
-        audio_channels = 2;
+        parse_option(o, "ac", "2", options);
 
     } else {
         fprintf(stderr, "Unknown target: %s\n", arg);
@@ -4061,7 +4054,7 @@ static const OptionDef options[] = {
     { "aframes", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_frames}, 
"set the number of audio frames to record", "number" },
     { "aq", OPT_FLOAT | HAS_ARG | OPT_AUDIO, {(void*)&audio_qscale}, "set 
audio quality (codec-specific)", "quality", },
     { "ar", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_rate}, "set audio sampling 
rate (in Hz)", "rate" },
-    { "ac", HAS_ARG | OPT_AUDIO, {(void*)opt_audio_channels}, "set number of 
audio channels", "channels" },
+    { "ac", HAS_ARG | OPT_AUDIO | OPT_INT | OPT_SPEC, {.off = 
OFFSET(audio_channels)}, "set number of audio channels", "channels" },
     { "an", OPT_BOOL | OPT_AUDIO | OPT_OFFSET, {.off = OFFSET(audio_disable)}, 
"disable audio" },
     { "acodec", HAS_ARG | OPT_AUDIO | OPT_FUNC2, {(void*)opt_audio_codec}, 
"force audio codec ('copy' to copy stream)", "codec" },
     { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, 
{(void*)opt_audio_tag}, "force audio tag/fourcc", "fourcc/tag" },
-- 
1.7.5.4

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to