From e911e208b850b68ba60555526d69fb329fbccb4f Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 23 Jun 2016 12:14:45 +0200 Subject: af_lavcac3enc: make encoder configurable --- DOCS/man/af.rst | 6 +++++- audio/filter/af_lavcac3enc.c | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DOCS/man/af.rst b/DOCS/man/af.rst index be90f09b62..8fe60250fb 100644 --- a/DOCS/man/af.rst +++ b/DOCS/man/af.rst @@ -70,7 +70,7 @@ Available filters are: Set AVOptions on the SwrContext or AVAudioResampleContext. These should be documented by FFmpeg or Libav. -``lavcac3enc[=tospdif[:bitrate[:minch]]]`` +``lavcac3enc[=options]`` Encode multi-channel audio to AC-3 at runtime using libavcodec. Supports 16-bit native-endian input format, maximum 6 channels. The output is big-endian when outputting a raw AC-3 stream, native-endian when @@ -103,6 +103,10 @@ Available filters are: If the input channel number is less than ````, the filter will detach itself (default: 3). + ``encoder=`` + Select the libavcodec encoder used. Currently, this should be an AC-3 + encoder, and using another codec will fail horribly. + ``equalizer=g1:g2:g3:...:g10`` 10 octave band graphic equalizer, implemented using 10 IIR band-pass filters. This means that it works regardless of what type of audio is diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c index 6eb71643dd..5c28bdfd17 100644 --- a/audio/filter/af_lavcac3enc.c +++ b/audio/filter/af_lavcac3enc.c @@ -62,6 +62,7 @@ typedef struct af_ac3enc_s { int cfg_add_iec61937_header; int cfg_bit_rate; int cfg_min_channel_num; + char *cfg_encoder; } af_ac3enc_t; // fmt carries the input format. Change it to the best next-possible format @@ -374,9 +375,9 @@ static int af_open(struct af_instance* af){ af->filter_frame = filter_frame; af->filter_out = filter_out; - s->lavc_acodec = avcodec_find_encoder_by_name("ac3"); + s->lavc_acodec = avcodec_find_encoder_by_name(s->cfg_encoder); if (!s->lavc_acodec) { - MP_ERR(af, "Audio LAVC, couldn't find encoder for codec %s.\n", "ac3"); + MP_ERR(af, "Couldn't find encoder %s.\n", s->cfg_encoder); return AF_ERROR; } @@ -426,12 +427,14 @@ const struct af_info af_info_lavcac3enc = { .cfg_add_iec61937_header = 1, .cfg_bit_rate = 640, .cfg_min_channel_num = 3, + .cfg_encoder = "ac3", }, .options = (const struct m_option[]) { OPT_FLAG("tospdif", cfg_add_iec61937_header, 0), OPT_CHOICE_OR_INT("bitrate", cfg_bit_rate, 0, 32, 640, ({"auto", 0}, {"default", 0})), OPT_INTRANGE("minch", cfg_min_channel_num, 0, 2, 6), + OPT_STRING("encoder", cfg_encoder, 0), {0} }, }; -- cgit v1.2.3