diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-11-23 10:18:01 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-12-04 14:07:36 +0100 |
commit | 425889396137451ae30288c84122e28532b71596 (patch) | |
tree | 81cafc380027735076a86d6fc34185d4a3f4a217 /fftools/ffmpeg.c | |
parent | b9c928a486fda3c0d79b153591ac86beb1c53708 (diff) | |
download | ffmpeg-425889396137451ae30288c84122e28532b71596.tar.gz |
ffmpeg: make -bits_per_raw_sample a per-output-stream option
Also, document it and make it apply to audio in addition to video.
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r-- | fftools/ffmpeg.c | 11 |
1 files changed, 7 insertions, 4 deletions
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 |