summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-10-18 21:51:01 +0000
committerjstebbins <[email protected]>2011-10-18 21:51:01 +0000
commit4570769bdde73f0451f331da1e48ba80c437c399 (patch)
tree0a452b4340d55e22dcb9466a7f1ae7ce2c46f0bd /libhb
parentdf1968b6f1617e5a71d7140c5ec4a4305d674df3 (diff)
better detection of Libav audio bitrate
For some codecs, Libav does not set the codec context bitrate. They expect you to compute it from bits per sample, sample rate, and channels. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4298 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/stream.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libhb/stream.c b/libhb/stream.c
index a5401ec18..4d24be86d 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -4889,7 +4889,13 @@ static void add_ffmpeg_audio( hb_title_t *title, hb_stream_t *stream, int id )
}
audio->config.in.codec_param = codec->codec_id;
- audio->config.in.bitrate = codec->bit_rate? codec->bit_rate : 1;
+ int bps = av_get_bits_per_sample(codec->codec_id);
+ if( bps && codec->sample_rate && codec->channels )
+ audio->config.in.bitrate = bps * codec->sample_rate * codec->channels;
+ else if( codec->bit_rate )
+ audio->config.in.bitrate = codec->bit_rate;
+ else
+ audio->config.in.bitrate = 1;
audio->config.in.samplerate = codec->sample_rate;
audio->config.in.samples_per_frame = codec->frame_size;
audio->config.in.channel_layout = layout;