aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-06 19:15:16 +0100
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2013-01-07 00:55:00 +0100
commit302d2591dc6bab2561c7fe63e545c7909fecee5f (patch)
tree1f6f5f9217c27f3bd5ccb1f22cceca742ff4152a
parent10ac44198d83dc77d0078af78c0615441c9ce3c2 (diff)
downloadffmpeg-302d2591dc6bab2561c7fe63e545c7909fecee5f.tar.gz
ff_get_audio_frame_size: try to fix wma in wav
Fixes Ticket1905, Ticket2114 Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 2713e43ac85245805db95048493dde121a20aee7)
-rw-r--r--libavformat/utils.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 38be37e779..21f2a0ebb8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -846,6 +846,13 @@ static int get_audio_frame_size(AVCodecContext *enc, int size, int mux)
if (enc->frame_size > 1)
return enc->frame_size;
+ //For WMA we currently have no other means to calculate duration thus we
+ //do it here by assuming CBR, which is true for all known cases.
+ if(!mux && enc->bit_rate>0 && size>0 && enc->sample_rate>0 && enc->block_align>1) {
+ if (enc->codec_id == AV_CODEC_ID_WMAV1 || enc->codec_id == AV_CODEC_ID_WMAV2)
+ return ((int64_t)size * 8 * enc->sample_rate) / enc->bit_rate;
+ }
+
return -1;
}