From 425889396137451ae30288c84122e28532b71596 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 23 Nov 2021 10:18:01 +0100 Subject: ffmpeg: make -bits_per_raw_sample a per-output-stream option Also, document it and make it apply to audio in addition to video. --- fftools/ffmpeg.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'fftools/ffmpeg.c') diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index cfb04d5eff..03aec1af11 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3329,13 +3329,16 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) switch (enc_ctx->codec_type) { case AVMEDIA_TYPE_AUDIO: enc_ctx->sample_fmt = av_buffersink_get_format(ost->filter->filter); - if (dec_ctx) - enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample, - av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3); enc_ctx->sample_rate = av_buffersink_get_sample_rate(ost->filter->filter); enc_ctx->channel_layout = av_buffersink_get_channel_layout(ost->filter->filter); enc_ctx->channels = av_buffersink_get_channels(ost->filter->filter); + if (ost->bits_per_raw_sample) + enc_ctx->bits_per_raw_sample = ost->bits_per_raw_sample; + else if (dec_ctx) + enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample, + av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3); + init_encoder_time_base(ost, av_make_q(1, enc_ctx->sample_rate)); break; @@ -3378,7 +3381,7 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame) enc_ctx->width != dec_ctx->width || enc_ctx->height != dec_ctx->height || enc_ctx->pix_fmt != dec_ctx->pix_fmt) { - enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample; + enc_ctx->bits_per_raw_sample = ost->bits_per_raw_sample; } // Field order: autodetection -- cgit v1.2.3