--- modules/stream_out/transcode.c~	2006-09-22 05:29:10.000000000 +1000
+++ modules/stream_out/transcode.c	2007-01-15 14:04:33.000000000 +1100
@@ -1255,7 +1255,7 @@
         audio_BitsPerSample( id->p_decoder->fmt_out.i_codec );
     fmt_last = id->p_decoder->fmt_out;
     /* FIX decoders so we don't have to do this */
-    fmt_last.audio.i_rate = id->p_decoder->fmt_in.audio.i_rate;
+//    fmt_last.audio.i_rate = id->p_decoder->fmt_in.audio.i_rate;
 
     /*
      * Open encoder
@@ -1294,6 +1294,15 @@
     id->p_encoder->fmt_in.audio.i_bitspersample =
         audio_BitsPerSample( id->p_encoder->fmt_in.i_codec );
 
+    /* Fix AAC SBR changing number of channels and sampling rate */
+    if( (id->p_decoder->fmt_in.i_codec == VLC_FOURCC('m','p','4','a')) &&
+        (fmt_last.audio.i_rate != id->p_encoder->fmt_in.audio.i_rate) &&
+        (fmt_last.audio.i_channels != id->p_encoder->fmt_in.audio.i_channels) )
+    {
+      id->p_encoder->fmt_in.audio.i_rate = fmt_last.audio.i_rate;
+      id->p_encoder->fmt_out.audio.i_rate = fmt_last.audio.i_rate;
+    }
+
     /* Load conversion filters */
     if( fmt_last.audio.i_channels != id->p_encoder->fmt_in.audio.i_channels ||
         fmt_last.audio.i_rate != id->p_encoder->fmt_in.audio.i_rate )
