New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Has anyone succeeded in geting aac streaming to icecast? #185

Closed
ghost opened this Issue Apr 23, 2017 · 45 comments

Comments

Projects
None yet
4 participants
@ghost
Copy link

ghost commented Apr 23, 2017

I seem to have all the right codecs installed. The LT status page says it is connected to aac, even when the stream is disabled. The streams portion in config just says 'Getting information from server'.
I have a vague recollection of having to do a special compile of LiquidSoap to do this in AT 2.5x.
Is this still needed?

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 23, 2017

If you are on Debian or Ubuntu the recompile is probably still needed, the package on those distros hasn't been updated in ages :( I think the Rabe Liquidsoap Distribution (RaBe LSD) CentOS package has working aac but I haven't tested that yet.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 23, 2017

I am on Ubuntu Trusty. Daniel James in AT (actually he is part of the LS team) did a compile that worked with 2.5.2a on Ubuntu 12.07 at least. But I can't find it now.

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 23, 2017

I'd assume that that binary is on http://apt.sourcefabric.org/ with the related build scripts being in https://github.com/Airtime/airtime-packaging/tree/master/liquidsoap. I think this is something we need to port off of that mirror.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 23, 2017

Update. I now have it working and it is a very simple fix.

The latest stable LS binaries in Ubuntu & Debian distributions (and probably others) omitted to dynamically load external decoders are startup, by mistake. So, the fkaac encoder codec will not load and that is why it does not work without a recompile of Liquidsoap which I, and many others, have found difficult/impossible in my distribution (missing/deleted dependencies in repositories).

Easy Workaround.
There is also an internal ACC internal codec, which is not as good at compression, which was disabled in the settings by Albert S. I re-enabled it and disabled the non-working external one. I suggest that at least for the meantime that this should be committed as it is a simple 2 minute fix. At least it works and I can't tell the difference between 128k MP3 and 96k AAC, so it is not that bad.

Edit: /usr/local/lib/python2.7/dist-packages/airtime_playout-1.0-py2.7.egg/liquidsoap/acc.liq
Change the FDK-AAC section to look like it does in the attachment. It won't paste here properly.
Code snippet here: acc.txt

@hairmare for info

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 23, 2017

Further notes.
I tried the internal AAC+ internal codec and it is terrible (sounds like a cheap transistor radio in a tin bucket), don't even bother.
Opus works but when used on it's own with no other output stream types and certainly not when OGG is enabled in another stream. I found that this had been reported as a LS bug years ago but remains unfixed.
I suggest Opus and ACC+ are removed from the stream type selector in the Streams Page & docs until it is resolved. That will at least save future user issue reports

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 24, 2017

The soon to be released Liquidsoap 1.3.0 is dropping both the aac and aacplus codec in favor of fdk-aac so it looks like we should be switching to fdk-aac and drop the legacy aac and aacplus codecs in the long term.

We do need to ensure that there is a working install process that results in a useable system. I believe that there might be copyright issues with using aac/aacplus in Debian (which is why I assume the rebuild was needed in the past). I think that fdk-aad was released as opensource via android and it might have a licence that Debian considers free enough to include. The way I understand this Debian want's to ensure that the code isn't only open but also not encumbered by any patents.

Do you have a link to the opus issue? I'd like to try figuring out if we can take care of it at it's root. I remember doing some liquidsoap testing and then figuring out that opus in an ogg container works where raw opus doesn't work. At least in the streaming case using opus in an ogg container might be feasible.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 24, 2017

Well, it got AAC working (whereas fdk-aac is broken in public LS distributions and Libretime install) and may be useful in a FAQ (with disclaimer) and this topic marked 'solved'. As 30% of our listeners used it, the boss had me fix it. OPUS does seem to use the same container as OGG. We saw (Xiph directory) that almost nobody uses Opus for broadcast and are not worried if it even disappeared. Incoming Opus, however, may become more popular. The bug report from 2014: https://bugs.launchpad.net/ubuntu/+source/liquidsoap/+bug/1404657

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 24, 2017

I was able to reproduce that using both "OGG Vorbis" and "Opus" on Ubuntu Trusty doesn't work. It looks like the linked issue was fixed in liquidsoap 1.2.1 as I was able to use both streams on a CentOS box with an updated liquidsoap. I'm trying to reproduce this using an opam install on Ubuntu Trusty but haven't had any success with opam so far.

Regarding aac vs. fdkaac... The following comment from the code seems pretty legit.

FDK-AAC is the only good AAC encoder. libvoaac is deprecated and aacplus is subpar.
The difference in compression quality is clearly audible. -- Albert

I'd prefer to figure out what exactly is wrong with the install since the comment suggests that it was working on Ubuntu at some point.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 24, 2017

As I previously said above, the Debian & Ubuntu distributed LS 1.1.1 does not load dynamic plugins at startup - this includes the fkaac plugin - so it never gets loaded and therefore cannot work as is mentioned in many places. There was a commit that missed the publication by a few days that fixed it. This is why a compile from source works, if you succeed in doing it. However, I carefully followed their compile instructions to the letter (both methods) and they both failed as a couple of required files have been deleted from the referenced ancient repos. I found dozens of posts on the web, from sad folks like me, who did not manage it either at least in Ubuntu Trusty and Debian Jessie. Good luck :)

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 24, 2017

PS I think some went back to an earlier version and used that.

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 24, 2017

It kinda sucks that debian#841871 hasn't been fixed 😞 There are heaps more reported against debian and ubuntu that would probably be fixed by the update.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 24, 2017

I think I would back-burner it and get on with something else, pending the new LS.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 24, 2017

Maybe you can lift it from AT?

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 24, 2017

Absolutely, the code is already in https://github.com/Airtime/airtime-packaging/tree/master/liquidsoap and I'm waiting for 1.3.0 to be released so we can try getting it bumped in Debian and Ubuntu.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 24, 2017

You could always put it in a private ppa

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 25, 2017

Random thought: apt-get install libretime would be even cooler ;)

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 25, 2017

apt-get install libretime as being worked on in #132 😉

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 28, 2017

Another update on the AAC situation, I did some testing against liquidsoap 1.3.0 (installed and patched as per #192).

On CentOS I can run both an AAC and an Ogg/Vorbis stream in parallel and AAC seemed to sound fine, I didn't have any success with AAC on Ubuntu Trusty. The difference I could find so far is that my CentOS has fdk-aac 0.1.4 from nux dextop but Ubuntu Trusty is still on 0.1.2-1. I'm hoping Ubuntu Xenial fixes this with 0.1.3+20140816-2.

BTW, I have yet to start integrating the DAB+ flavor of fdk-aac I actually want to be able to use. A bit offtopic but maybe DAB+ is something you might be interested in given you are in the UK.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 28, 2017

My Ubuntu Trusty is on 1.1.1 - just for info.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 28, 2017

One of our guys made a test setup using DAB a year or so ago, but not on AT. Streaming into ROKU (almost the same as YouTube) is more interesting, but I do that using ffmpeg, externally.

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 28, 2017

My Ubuntu Trusty is on 1.1.1 - just for info.

I know, all Debian/Ubuntu liquidsoap versions are still 1.1.1 😢 We need to get that sorted and IMO the best solution is somehow switching to 1.3.0 as per #192

Streaming into ROKU (almost the same as YouTube) is more interesting, but I do that using ffmpeg, externally

Sounds interesting. Are you in the Channel Store? Is it based on streaming MPEG-H Audio? In theory it might be doable through gstreamer with liquidsoap but that's pretty much post 3.0.0 release land at this stage.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Apr 28, 2017

Not in the channel store. We did it as an experiment on a private channel. We cheated. airtime->icecast->ffmpeg. It is not really necessary to have it inside the engine. We did the same to youtube.

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 28, 2017

I wouldn't consider that to be cheating, audio engineers are allowed to be creative after all 😉 If we get ALSA output to work in a useable manner you could also do libretime->alsa->spdif->alsa->ffmpeg as a chain 😛.

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 28, 2017

The Ubuntu Trusty/liquidsoap 1.3.0 (opam install) combo has working AAC with an additional opam install fdkaac as user liquidsoap.

If you want to patch from a tarball, applying master...radiorabe:feature/liquidsoap-1.3.0 and jumping through the install hoops documented in #192 should now get you a working AAC stream based on fdkaac that sounds quite ok.

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Apr 28, 2017

You would need to follow the git instructions for the opam install, this is all very new.

@aresstokrat

This comment has been minimized.

Copy link

aresstokrat commented Jun 6, 2017

@hairmare main feature why i moved from RadioCMS to LT was AAC stream.
Is it possible to run fdk-aac codec stream on Jessie via liquidsoap and LT?
Is this correct:

  1. make liquidsoap 1.3.1 package under debian and install it (couse opam install seems like a bigger work)
  2. install fkd-aac from here https://packages.debian.org/source/jessie/misc/fdk-aac
  3. patch LT as you made it here master...radiorabe:feature/liquidsoap-1.3.0

?

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Jun 6, 2017

  1. make liquidsoap 1.3.1 package under debian and install it (couse opam install seems like a bigger work)

Using opam is probably the easiest way to install liquidsoap 1.3.1. If you are able to make a 1.3.1 .deb package I'm sure other people would appreciate that very much! It's bound to be more work than just using opam though.

  1. install fkd-aac from here https://packages.debian.org/source/jessie/misc/fdk-aac

This should be available through apt install fdk-aac. If you use opam, the opam depext command will install all build dependencies using native os packages.

  1. patch LT as you made it here master...radiorabe:feature/liquidsoap-1.3.0

Exactly. There will be some more docs on this in the 3.0.0-alpha.2 release notes (edit: I copied them to #192 and added a short git example). Those will focus on applying the patch to a downloaded tarball. Let us know if you need any assistance with applying the patch to your working copy (I'm assuming you are on a git install).

Please let us know if your liquidsoap install works out in the liquidsoap 1.3.x issue #192.

@aresstokrat

This comment has been minimized.

Copy link

aresstokrat commented Jun 7, 2017

Ok, thank you for your answer! Couse i will not be able to make a .deb since im not pro in linux and only can folow insctructions. I will folow your instruction in #192

As i understood i have to git clone tarball and then install patch and reinstall LT as you described in #192

I'm nervous about reinstalling, i think it will ruin DB, services configuration we recently made and settings.

Can i apply this patch on working LT without reinstall ?

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Jun 7, 2017

I'm nervous about reinstalling, i think it will ruin DB, services configuration we recently made and settings.

The DB should be safe, anything systemd should be safe as well for now (this will change when the installer learns to write the files). I would absolutely recommend that you create a backup of your /etc/airtime folder and then restore that instead of redoing the setup wizard.

In any case you should take regular backups of the database, file storage and, config. Preferably you would also have a backup of the complete machine so you can rollback in case something goes wrong. More info on backuping you DB is in the manual and there is also a section about upgrading that touches on this a bit.

Can i apply this patch on working LT without reinstall ?

Sure...

  1. just grab the *.liq files and the liquidsoap_auth.py from here and copy them over the installed files in /usr/local/lib/python2.7/dist-packages/airtime_playout-1.0-py2.7.egg/liquidsoap.
  2. Hack /usr/local/lib/python2.7/dist-packages/airtime_playout-1.0-py2.7.egg/liquidsoap/__main__.py so the last lines point to the liquidsoap binary installed by opam instead of /usr/bin/liquidsoap (you can run which liquidsoap to get this).
  3. Restart the airtime-liquidsoap service and you should be good to go.
@aresstokrat

This comment has been minimized.

Copy link

aresstokrat commented Jun 9, 2017

Thank you for your mighty help ! 👍
there was ton of problems installing liquidsoap 1.3.1 from opam (fatal errors during opam init and much more), but i managed to do that at the end, and i cant even say how :(
spent 5 hours :)))
Strange, but apt-get remove liquidsoapdeleted airtime-liquidsoap,analyzer and playout from systemd services. (i did't remove anything else so i think its fault of the apt-get).
Its very wierd couse i installed this services manualy with your help #213 (comment)

repeated procedure with same instructions. Did't work, services did't want to load after systemctl daemon-reload so i manualy deleted all init.d files referenced to airtime.
Only after that its goes as it should be. Disabling init.d scripts wount help.

Made all the hacks on working copy.
In the admin panel i choose second stream and enabled AAC (this is served by fdk-aac?). Its started, its playing. AAC96 vs MP3128 loosing, it sound like no high freq. , very flat.
How can i check that this is realy fdk-aac not some other codec?

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Jun 9, 2017

If the liquidsoap upgrade worked you must be on fdk-aac, support for the old aac and aacplus encoders was removed in liquidsoap 1.3.1. Did you double check that airtime-liquidsoap is using the opam binary?

What bitrates are you using? The script switches aac+ profiles based on it. With bitrates >= 96 it encodes an mpeg4_aac_lc audio object type and with bitrates <= 64 it does the mpeg4_he_aac_v2 type. I assume that the latter sounds better since the fdk-aac code was optimized for mobile use and probably concentrates on low bitrates more than on the hi def stuff.

You are most likely using fdk-aac 1.4.1... It looks like the recent 1.5.1 release hasn't made it into all distros and could improve sound quality but I'm not sure about this (it's most radio digitale mondiale (DRM) supprt afaik). The changeset does seem to include some fixes to using the ARM neon extensions but I'm not sure if those are relevant on a Raspberry Pi.

@aresstokrat

This comment has been minimized.

Copy link

aresstokrat commented Jun 13, 2017

Im using AAC 96 bitrate in stream config of LT .
"Mobile" unchecked, since i don't know what is it :)

$ /usr/bin/liquidsoap --version
Liquidsoap 1.3.1
Copyright (c) 2003-2017 Savonet team
Liquidsoap is open-source software, released under GNU General Public License.
See <http://liquidsoap.fm> for more information.
ls -la /usr/bin/liquidsoap
lrwxrwxrwx 1 root root 49 июн  8 17:44 /usr/bin/liquidsoap -> /usr/share/liquidsoap/.opam/system/bin/liquidsoap

opam install depext taglib mad lame vorbis cry opus fdkaac liquidsoap
- install fdkaac.0.2.1

@hairmare you can also compare 2 different streams:
http://firefm.linkpc.net:8000/mp3-128
http://firefm.linkpc.net:8000/aac96

about internet bandwidth, mp3-128 eats 17-20 k/s
and aac-96 eats 12-13 k/s

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Jun 15, 2017

I think the "Mobile" flag only concerns what streams are advertised to anyone using the player on the radio page. We should probably explain this in the docs once we are sure what it does.

Your aac96 clearly sounds a lot flatter than the mp3 stream.

You might want to try a lower bitrate. If you use 64k or lower the codec uses a different audio object type that might in fact sound better. I assume that AAC LC works better on higher bitrates, basically using it at 96k is probably pushing the codec to it's limit and AAC HEv2 might sound better at lower bit rates.

I found this reddit post that links a nice graph of how the profiles compare:

http://i231.photobucket.com/albums/ee166/img_f/figure_1.png

From my experience with DAB+ (which uses AAC+) I've only seen the AAC codec used in the streaming parts of broadcast applications at bit rates starting from 64k and going down right to 32k for ie. talk channels. In broadcast the higher bit rates might get used on a studio transmitter link over a dedicated line with bit rates of 128k and up.

To get the best performance out of most codecs, targeted on-air-processing can also help. Currently LibreTime doesn't do anything like that to the signal before encoding it. It seems lot's of broadcast solutions use dedicated hardware with professionally tuned acoustic models to do this.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Jun 15, 2017

'Flatter'? Is it using some sort of level compressor?

@aresstokrat

This comment has been minimized.

Copy link

aresstokrat commented Jun 15, 2017

No comperssor at all. Only installation of liquidsoap 1.3.1, fdk-aac and hacks of LT as it writen above.
@hairmare i will try to lay down to 64k tomorow! As a third stream to compare.

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Jun 15, 2017

@Robby262 As far as I understand this the fdk-aac codec itself does apply some compression based on loudness metadata as part of how it works. Maybe 'flatter' wasn't the word I was looking for, I was trying to describe the clearly audible difference from the mp3 to the aac96 in aresstokrats stream.

@aresstokrat Cool, It should be interesting to be able to compare the two profiles. I've only really compared this fdk-aac fork with low HEv2 bit rates to FM and to an mp3 stream that has optimization potential processing wise.

@ghost

This comment has been minimized.

Copy link
Author

ghost commented Jun 16, 2017

The legacy aac that I renabled in LS_script sounds fine @96k

@aresstokrat

This comment has been minimized.

Copy link

aresstokrat commented Jun 16, 2017

Now we can compare all 3 streams. Definitely 64k (AAC HEv2) sounds better then 96k
http://firefm.linkpc.net:8000/mp3-128
http://firefm.linkpc.net:8000/aac96
http://firefm.linkpc.net:8000/aac64

MP-128k has much more details than 64k. Maybe its ok? What is your experience in direct compare?

@ghost ghost closed this Jul 15, 2017

@yarik2720

This comment has been minimized.

Copy link

yarik2720 commented Nov 19, 2017

Hi! Need help here!
I tried to build liquidsoap from source with fdkaac support (as described here: http://web.archive.org/web/20130906192421/https://wiki.sourcefabric.org/display/CC/Building+Liquidsoap+from+Source)
But after I making sudo cp liquidsoap-full/liquidsoap/src/liquidsoap /usr/bin/liquidsoap airtime-service don't starts.
Liquidsoap "from box" can't load fdkaac library.
Here are logs from ls_script:

2017/11/19 13:19:55 >>> LOG START
2017/11/19 13:19:54 [protocols.external:3] Found "/usr/bin/wget".
2017/11/19 13:19:54 [main:3] Liquidsoap 1.1.1
2017/11/19 13:19:54 [main:3] Using: graphics=[distributed with Ocaml] pcre=7.0.4 dtools=0.3.1 duppy=0.5.1 duppy.syntax=0.5.1 cry=0.2.2 mm=0.2.1 xmlplaylist=0.1.3 lastfm=0.3.0 ogg=0.4.5 vorbis=0.6.1 o$
2017/11/19 13:19:54 [dynamic.loader:3] Error while loading dynamic fdkaac encoder at /usr/lib/ocaml/fdkaac
2017/11/19 13:19:54 [dynamic.loader:3] Error while loading dynamic fdkaac encoder at /usr/local/lib/ocaml/4.02.3/fdkaac
2017/11/19 13:19:54 [dynamic.loader:3] Could not find dynamic module for fdkaac encoder.
2017/11/19 13:19:54 [dynamic.loader:3] Could not find dynamic module for aacplus encoder.

@Robbt Robbt reopened this Nov 20, 2017

@yarik2720

This comment has been minimized.

Copy link

yarik2720 commented Nov 21, 2017

some additions:

$ sudo airtime-liquidsoap --debug
Airtime Liquidsoap
DEBUG:root:http://************:8080/api/get-stream-setting/format/json/api_key/Q9V8EM5T8Q01FG3Z0AKZ/
Error: expected an encoding format after %ifencoder!
@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Nov 23, 2017

The expected an encoding format after %ifencoder seems to indicate something lacking in the generated liquidsoap.cfg file. I didn't find time to dig into this yet.

Are you sure you really need to use AAC+ (esp. the fdkaac implementation)?

My current understanding is that the fdkaac stuff hasn't seen enough love for it to make sense in comparison to purpose built AAC+ coders on fraunhofer licenses with a broadcast oriented codec tuning. In fact, our DAB+ provider has switched from a forked fdkaac implementation to using a proprietary product due it's better performance for broadcast on lower bitrates.

Do you really need AAC+? If you're just aiming for a lower bandwidth; wouldn't Opus do the job just fine? I'd be really glad if you could explain the business case for AAC+, after really looking into it over the past couple of months I only see marginal benefits to be had from using fdkaac in broadcast scenarios as opus performs really well in the use cases I've seen so far.

@yarik2720

This comment has been minimized.

Copy link

yarik2720 commented Nov 23, 2017

AAC+ have huge support platform, also it have big plus for internet-radio platforms such as TuneIn, because it can be easily played on most platforms and browsers. For mobile internet it have good compression quality (as you showed in image higher) and can be used for music too (not only talks).
I already used that codec (fdkaac) on my production server with airtime 2.5.1 and it shows good results at 32kbps and 64kbps

@Robbt Robbt added the liquidsoap label Jan 27, 2018

@Robbt Robbt added the help wanted label Jan 19, 2019

@Robbt

This comment has been minimized.

Copy link
Member

Robbt commented Jan 19, 2019

According to @paddatrapper on the discourse forum - "It is possible to use AAC+ in liquidsoap by installing libfdkaac-ocaml-dynlink from contrib in Debian or multiverse in Ubuntu. I haven’t tested this with LibreTime, but it should just work after a restart"

@hairmare

This comment has been minimized.

Copy link
Member

hairmare commented Jan 20, 2019

My CentOS packages can dynload aac as well. I'm not putting much effort into that due to this warning on the gnu license list.

I did some cleanup to the liquidsoap code pertaining to aac in #706 and I guess we can close this since there isn't really anything actionable left to do here.

@hairmare hairmare closed this Jan 20, 2019

@Robbt

This comment has been minimized.

Copy link
Member

Robbt commented Jan 20, 2019

Hmm, I think it might be helpful to add something to the docs that explains this and links to the warning and allows people to make an informed decision as to what they want to do. I know a lot of people will be tempted to use aac because it is widely supported by various clients and has a higher quality at a lower bit rate. In addition we could add some docs on how to support opus as an alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment