[FFmpeg-cvslog] avcodec/libfaac: fallback to a supported bitrate if the requested is not supported

Michael Niedermayer git at videolan.org
Thu May 23 15:43:15 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed May 22 15:12:36 2013 +0200| [eee19198ef5aed3b99ac0b136685bd28e6717f61] | committer: Michael Niedermayer

avcodec/libfaac: fallback to a supported bitrate if the requested is not supported

Fixes: Ticket2587

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eee19198ef5aed3b99ac0b136685bd28e6717f61
---

 libavcodec/libfaac.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c
index ac18fe2..f37e03a 100644
--- a/libavcodec/libfaac.c
+++ b/libavcodec/libfaac.c
@@ -151,9 +151,20 @@ static av_cold int Faac_encode_init(AVCodecContext *avctx)
     }
 
     if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
-        av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
-        ret = AVERROR(EINVAL);
-        goto error;
+        int i;
+        for (i = avctx->bit_rate/1000; i ; i--) {
+            faac_cfg->bitRate = 1000*i / avctx->channels;
+            if (faacEncSetConfiguration(s->faac_handle, faac_cfg))
+                break;
+        }
+        if (!i) {
+            av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
+            ret = AVERROR(EINVAL);
+            goto error;
+        } else {
+            avctx->bit_rate = 1000*i;
+            av_log(avctx, AV_LOG_WARNING, "libfaac doesn't support the specified bitrate, using %dkbit/s instead\n", i);
+        }
     }
 
     avctx->delay = FAAC_DELAY_SAMPLES;



More information about the ffmpeg-cvslog mailing list