Also document it.
---
avconv.c | 37 +++++++++++++------------------------
cmdutils.c | 10 ++++++++++
doc/avconv.texi | 3 +++
doc/fftools-common-opts.texi | 2 +-
4 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/avconv.c b/avconv.c
index f67906d..3f398e4 100644
--- a/avconv.c
+++ b/avconv.c
@@ -105,7 +105,6 @@ static int frame_width = 0;
static int frame_height = 0;
static float frame_aspect_ratio = 0;
static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
-static enum AVSampleFormat audio_sample_fmt = AV_SAMPLE_FMT_NONE;
static AVRational frame_rate;
static float video_qscale = 0;
static uint16_t *intra_matrix = NULL;
@@ -319,6 +318,8 @@ typedef struct OptionsContext {
int nb_bitstream_filters;
SpecifierOpt *codec_tags;
int nb_codec_tags;
+ SpecifierOpt *sample_fmts;
+ int nb_sample_fmts;
} OptionsContext;
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
@@ -2571,24 +2572,6 @@ static int opt_top_field_first(const char *opt, const
char *arg)
return 0;
}
-static int opt_audio_sample_fmt(const char *opt, const char *arg)
-{
- if (strcmp(arg, "list")) {
- audio_sample_fmt = av_get_sample_fmt(arg);
- if (audio_sample_fmt == AV_SAMPLE_FMT_NONE) {
- av_log(NULL, AV_LOG_ERROR, "Invalid sample format '%s'\n", arg);
- return AVERROR(EINVAL);
- }
- } else {
- int i;
- char fmt_str[128];
- for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
- printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str),
i));
- exit_program(0);
- }
- return 0;
-}
-
static int opt_audio_rate(const char *opt, const char *arg)
{
audio_sample_rate = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
@@ -3000,7 +2983,6 @@ static int opt_input_file(OptionsContext *o, const char
*opt, const char *filena
frame_width = 0;
audio_sample_rate = 0;
audio_channels = 0;
- audio_sample_fmt = AV_SAMPLE_FMT_NONE;
for (i = 0; i < orig_nb_streams; i++)
av_dict_free(&opts[i]);
@@ -3210,14 +3192,22 @@ static OutputStream *new_audio_stream(OptionsContext
*o, AVFormatContext *oc)
audio_enc->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
if (!st->stream_copy) {
+ char *sample_fmt = NULL;
+
if (audio_qscale > QSCALE_NONE) {
audio_enc->flags |= CODEC_FLAG_QSCALE;
audio_enc->global_quality = FF_QP2LAMBDA * audio_qscale;
}
if (audio_channels)
audio_enc->channels = audio_channels;
- if (audio_sample_fmt != AV_SAMPLE_FMT_NONE)
- audio_enc->sample_fmt = audio_sample_fmt;
+
+ MATCH_PER_STREAM_OPT(sample_fmts, str, sample_fmt, oc, st);
+ if (sample_fmt &&
+ (audio_enc->sample_fmt = av_get_sample_fmt(sample_fmt)) ==
AV_SAMPLE_FMT_NONE) {
+ av_log(NULL, AV_LOG_ERROR, "Invalid sample format '%s'\n",
sample_fmt);
+ exit_program(1);
+ }
+
if (audio_sample_rate)
audio_enc->sample_rate = audio_sample_rate;
}
@@ -3649,7 +3639,6 @@ static void opt_output_file(void *optctx, const char
*filename)
frame_height = 0;
audio_sample_rate = 0;
audio_channels = 0;
- audio_sample_fmt = AV_SAMPLE_FMT_NONE;
av_freep(&streamid_map);
nb_streamid_map = 0;
@@ -4087,7 +4076,7 @@ static const OptionDef options[] = {
{ "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" },
{ "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change
audio volume (256=normal)" , "volume" }, //
- { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO,
{(void*)opt_audio_sample_fmt}, "set sample format, 'list' as argument shows all
the sample formats supported", "format" },
+ { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_SPEC | OPT_STRING,
{.off = OFFSET(sample_fmts)}, "set sample format", "format" },
/* subtitle options */
{ "sn", OPT_BOOL | OPT_SUBTITLE | OPT_OFFSET, {.off =
OFFSET(subtitle_disable)}, "disable subtitle" },
diff --git a/cmdutils.c b/cmdutils.c
index 98e7bbb..b3f14ad 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -717,6 +717,14 @@ void show_pix_fmts(void)
}
}
+static void show_sample_fmts(void)
+{
+ int i;
+ char fmt_str[128];
+ for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
+ printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
+}
+
int show_help_common(const char *opt, const char *arg)
{
av_log_set_callback(log_callback_help);
@@ -733,6 +741,8 @@ int show_help_common(const char *opt, const char *arg)
show_pix_fmts();
else if (arg && !strcmp(arg, "filters"))
show_filters();
+ else if (arg && !strcmp(arg, "sample_fmts"))
+ show_sample_fmts();
else
show_help(opt, arg);
diff --git a/doc/avconv.texi b/doc/avconv.texi
index 827e0f9..d9c1461 100644
--- a/doc/avconv.texi
+++ b/doc/avconv.texi
@@ -590,6 +590,9 @@ and is mapped to the corresponding demuxer options.
Disable audio recording.
@item -acodec @var{codec}
Set the audio codec. This is an alias for @code{-codec:a}.
+@item -sample_fmt[:@var{stream_specifier}] @var{sample_fmt}
+Set the audio sample format. Use @code{-help sample_fmts} to get a list
+of supported sample formats.
@end table
@section Advanced Audio options:
diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index f003cc8..bd97e99 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -23,7 +23,7 @@ Show license.
@item -h, -?, -help, --help [@var{item}]
Show help. If @var{item} is specified, show help on it.
@var{item} may be one of @code{formats}, @code{codecs}, @code{bsfs},
-@code{protocols}, @code{filters}, @code{pix_fmts}.
+@code{protocols}, @code{filters}, @code{pix_fmts}, @code{sample_fmts}.
@item -version
Show version.
--
1.7.5.4
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel