On Tue, Sep 29, 2009 at 3:51 PM, jacob jacob <[email protected]> wrote:

> I have two questions
>
>
> 2) ffmpeg does not multiply sample rate of lc aac sbr, so final file
> plays in slow motion (22050 instead of 44100). ( note: faad itself
> perfectly converts and multiplys it by just itself out of ffmpeg ).
> How to solve this problem for ffmpeg?
>

I hacked ffmpeg as following :

@ libavformat/utils.c

Index: utils.c
===================================================================
--- utils.c     (revision 83)
+++ utils.c     (working copy)
@@ -1896,6 +1896,12 @@
             enc->codec_id == CODEC_ID_AAC ||
             enc->codec_id == CODEC_ID_SPEEX))
             return 0;
+        /* MUST decode some frames to fix SBR upsampling or
downsampling issue */
+        if(enc->codec_id == CODEC_ID_AAC && enc->sample_rate && !enc-
>codec){

+            enc->sample_rate = 0;
+            enc->channels = 0;
+            return 0;
+        }
         break;
     case CODEC_TYPE_VIDEO:
         val = enc->width && enc->pix_fmt != PIX_FMT_NONE;

//@ libavcodec/aac_ac3_parser.c

Index: aac_ac3_parser.c
===================================================================
--- aac_ac3_parser.c    (revision 83)
+++ aac_ac3_parser.c    (working copy)
@@ -71,7 +71,12 @@
     *poutbuf_size = buf_size;

     /* update codec info */
-    avctx->sample_rate = s->sample_rate;
+    /* we do not override AAC sample_rate because SBR+PS issue */
+    if(avctx->codec_id == CODEC_ID_AAC){
+        if(!avctx->sample_rate)
+            avctx->sample_rate = s->sample_rate;
+    }else
+        avctx->sample_rate = s->sample_rate;
     if(s->codec_id)
         avctx->codec_id = s->codec_id;

@@ -84,7 +89,12 @@
              avctx->codec_id == CODEC_ID_EAC3)))) {
         avctx->channels = avctx->request_channels;
     } else if (avctx->codec_id != CODEC_ID_AAC || s->channels) {
-        avctx->channels = s->channels;
+        /* we do not override AAC channels because SBR+PS issue */
+        if(avctx->codec_id == CODEC_ID_AAC){
+            if(!avctx->channels)
+                avctx->channels = s->channels;
+        }else
+            avctx->channels = s->channels;
         avctx->channel_layout = s->channel_layout;
     }
     avctx->bit_rate = s->bit_rate;

-- 
-----------------------------------------------------------------------------------------
My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2
Inspired by http://www.nextplayer.net. Your potential. Our passion.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to