Search code examples
ffmpegstreaminghttp-live-streamingicecast

How can i decode an mp3 and encode it as aac with ezstream


This is my current ezstream config

<ezstream>
   <url>http://localhost:8000/test</url>
   <sourcepassword>password</sourcepassword>
   <format>MP3</format>
   <filename>playlist.m3u</filename>
   <reencode>
      <enable>1</enable>
      <encdec>
         <format>MP3</format>
         <match>.mp3</match>
         <decode>madplay -b 16 -R 44100 -S -o raw:- "@T@"</decode>
         <encode>lame --preset cbr 32 -r -s 44.1 --bitwidth 16 - -</encode>
      </encdec>
   </reencode>
</ezstream>

It's mounting to an icecast server, its decoding and encoding mp3 to a lower bitrate, I'm trying to encode it to aac instead of mp3 in hopes that the quality improves as i heard that aac is better than mp3 for lower bitrates.

What i would like to know is if i can use an aac encoder such as FFmpeg instead of the lame mp3 encoder and get an aac to the end user instead of mp3, if so what parameters should i pass to FFmpeg so that it works with my current config.


Solution

  • Icecast doesn't officially support AAC due to licensing.

    Icecast is a streaming media server which currently supports Ogg (Vorbis and Theora), Opus, WebM and MP3 audio streams.

    Unofficially it might work in pass-trough mode, but you need to try and see for yourself.

    For FFmpeg AAC ecoding you should use the Fraunhofer FDK AAC library (libfdk_aac). You also need a streamable format like AAC in ADTS.

    Based on your example it seems it uses stdout to transcode. If you converted the MP3 to PCM using madplay you should be able to encode it to AAC using something like this:

    <encode>ffmpeg -f s16le -ar 44.1k -ac 2 -i - -b:a 32k -ar 44.1k -f adts -</encode>