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

谁都会走 提交于 2019-12-23 22:16:30

问题


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.


回答1:


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>



回答2:


I personally recommend the Opus codec. It's much better than MP3, including and especially at lower bit rates. Also no need to worry about buying an encoder license.

You can use avconv/ffmpeg instead of ezstream.

avconv -re -i http://someserver/stream.mp3 -c:a opus -b:a 20k \
       -application audio -vbr on -frame_duration 60 \
       -content_type audio/ogg \
       icecast://source:bar@server:8000/test-20.opus

This example will work with latest avconv and with latest Icecast (2.4.1).
There are packages for all major distros on http://icecast.org/download if your distro doesn't have that version.

BTW: If you insist on AAC, bought an encoder license etc. It's trivial to adapt the above example.



来源:https://stackoverflow.com/questions/29499768/how-can-i-decode-an-mp3-and-encode-it-as-aac-with-ezstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!