OpenWrt Forum Archive

Topic: iTunes server (forked-daapd)

The content of this topic has been archived between 28 Feb 2018 and 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

ejurgensen wrote:

The forked-daapd server no longer requires a modified version of sqlite3. Forked-daapd depends on a certain compile option in sqlite3 being enabled, and the good people of OpenWrt have now enabled it in trunk (since version 3070701-2 of sqlite3).

As forked-daapd no longer requires custom versions of any packages it'll be easier to install. Being compatible with trunk also means I can look into submitting it for inclusion.

Does your version contain the the patch for iTunes 10.5-> timeouts?


The patch is for libevent version, not the GCD-version. If I've understood correctly the openwrt version uses libevent atm. See: https://github.com/jasonmc/forked-daapd … nt-3328436

More detailed description of the problem and the patch itself can be found from here: https://github.com/CBGoodBuddy/forked-d … 6318b7d67d

Hopefully an easy way for applying the patch can be found from: https://github.com/jasonmc/forked-daapd … nt-3331508

My version is plain 0.19, so it's without the patch. And you're right, it's the libevent-version.

Thanks for bringing it to my attention, I'll look into applying it. Seems like an annoying bug, I wonder why upstream hasn't fixed it yet.

ejurgensen wrote:

My version is plain 0.19, so it's without the patch. And you're right, it's the libevent-version.

Thanks for bringing it to my attention, I'll look into applying it. Seems like an annoying bug, I wonder why upstream hasn't fixed it yet.

Hi,

any news on applying the patch? smile I'm just wondering if I should start setting up a build environment myself or not...


I probably should as the current version of forked-daapd segfaults on with the current snapshot (March 14.) of the trunk. At least on my wndr3800...

No news - I've been busy with some other stuff. I wasn't aware that it is broken with the current snapshot, thanks for reporting it.

It might take a while before I can look at the patch and fixing it, so it would be great if you would help. I'll send you a PM. Maybe we can also look at submitting it to OpenWrt, so it will be easier to maintain.

I'll try to take a look at applying the patch myself. Uni is also keeping me quite busy for the rest of springtime, so it might take a while also if I don't manage to do it during next weekend...

Oh, and about the segfault. It also might be that I didn't have all the proper libraries installed and services running last time I tried. I'll report back on weekend when I have time to try messing with the box again.

(Last edited by ssi on 12 Apr 2012, 18:06)

I finally got around to fixing this. Apparently my forked-daapd package has been broken since trunk moved away from kernel 2.6, which is very regrettable. This should all be fixed now, and I've also applied the patch suggested by ssi regarding iTunes 10.5 time-outs.

These changes are available in release 4 (see how to get here: http://wiki.openwrt.org/inbox/howto/forked-daapd). Release 3 is vanilla forked-daapd 0.19 fixed to work in current snapshot of trunk, but without the time-out patch.

I haven't gotten around to actually upgrading my router to current trunk, so these releases are untested. If anyone knows of a way to run trunk in a vm please let me know. It would make testing a lot easier.

Hi, I've installed forked-daapd but I can't get it to work. I get a database error on the log, but I don't think it even created the db.
Can someone please give me a tip?

Thanks

Log:
[2012-07-13 22:05:30]     main: Forked Media Server Version 0.19 taking off
[2012-07-13 22:05:30]     main: Initialized with gcrypt 1.5.0
[2012-07-13 22:05:30]     main: PID: 2502
[2012-07-13 22:05:30]     main: mDNS init
[2012-07-13 22:05:30]     mdns: Initializing Avahi mDNS
[2012-07-13 22:05:30]     mdns: Avahi state change: Client running
[2012-07-13 22:05:30]     mdns: Creating service group
[2012-07-13 22:05:30]     mdns: No entries yet... skipping service create
[2012-07-13 22:05:30]     main: Initializing database
[2012-07-13 22:05:30]       db: Could not open database: unable to open database file
[2012-07-13 22:05:30]     main: Database init failed
[2012-07-13 22:05:30]     main: mDNS deinit
[2012-07-13 22:05:30]     main: Exiting.

First thing to check is that the location of the database file is a valid path, and that forked-daapd has write access. You can also check if it creates the database file. Next you can try increasing the log-level - maybe it will say more specifically what is going wrong.

Do you know what revision of trunk you are running?

Hi, thanks for answering!

The log level is already spam and the trunk version is Bleeding Edge, r32603, I think the location is a valid path (at least I can create directories, I even tried on /etc/) but it doesn't seem to create anything.  How can I check if forked daapd has write access?

Well it's probably running as root (that's default), so if the path is valid then write access shouldn't be a problem. Your trunk version is newer than mine, but I don't see anything changed that could have broken forked-daapd. The error message is from sqlite3, but I'm out of ideas why it can't open the file.

I've updated the forked-daapd package with a small fix against libevent, which prevented it from building in trunk. I've also submitted it for inclusion in OpenWrt. It is now version 0.19, release 5.

I tried to install forked-daapd on my wr703n using extroot running on a usb flash stick.

Everything installed properly. When I try to start forked-daapd, I have a problem with shared libraries.

# /etc/init.d/forked-daapd start
/usr/sbin/forked-daapd: can't load library 'libavcodec.so.53'

The ones I have are libavcodec.so.54

What is the best way to fix this problem?

Thanks!

Hello !

I am an happy user of a Asus RT-N66U.
I already have installed a custom Shibby firmware and enwtware package system.
Now I would like to use forked-daapd on it.

So I installed toolchain like described here http://wiki.openwrt.org/doc/howto/buildroot.exigence , here : http://wiki.openwrt.org/doc/howto/build and here http://wiki.openwrt.org/doc/devel/crosscompile
I think I have now a toolchain ready for architecture "mipsel" (my router has BCM4706 CPU)

Now I try to use this http://wiki.openwrt.org/inbox/howto/forked-daapd  to build forked-daapd
As requested I have downloaded this package http://www.gyfgafguf.dk/openwrt/src/source.tar.gz

And I have this when i make :

make[3]: Entering directory `/home/.../openwrt/trunk/package/libantlr3c'
mkdir -p /home/.../openwrt/trunk/dl
/home/.../openwrt/trunk/scripts/download.pl "/home/.../openwrt/trunk/dl" "libantlr3c-3.2.tar.gz" "674646e1d1bf5c6015435480cead725a" "http://www.antlr.org/download/C"
--2013-06-09 13:05:04--  http://www.antlr.org/download/C/libantlr3c-3.2.tar.gz
Resolving www.antlr.org (www.antlr.org)... 138.202.170.10
Connecting to www.antlr.org (www.antlr.org)|138.202.170.10|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-06-09 13:05:06 ERROR 404: Not Found.

Download failed.
--2013-06-09 13:05:06--  http://mirror2.openwrt.org/sources/libantlr3c-3.2.tar.gz
Resolving mirror2.openwrt.org (mirror2.openwrt.org)... 46.4.11.11
Connecting to mirror2.openwrt.org (mirror2.openwrt.org)|46.4.11.11|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-06-09 13:05:06 ERROR 404: Not Found.

Download failed.
--2013-06-09 13:05:06--  http://downloads.openwrt.org/sources/libantlr3c-3.2.tar.gz
Resolving downloads.openwrt.org (downloads.openwrt.org)... 78.24.191.177
Connecting to downloads.openwrt.org (downloads.openwrt.org)|78.24.191.177|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2013-06-09 13:05:07 ERROR 404: Not Found.

Download failed.

Answer to myself (could be useful for others) :
put http://pkgs.fedoraproject.org/repo/pkgs … 80cead725a
in PKG_SOURCE_URL of openwrt/trunk/package/libantlr3c/Makefile

Now another problem :

checking for ld used by GCC... mipsel-openwrt-linux-uclibc-ld
checking if the linker (mipsel-openwrt-linux-uclibc-ld) is GNU ld... yes
checking for shared library run path origin... done
checking for iconv... no, consider installing GNU libiconv
checking for libunistring... yes
checking how to link with libunistring... -lunistring
checking pkg-config is at least version 0.9.0... yes
checking for ZLIB... yes
checking for CONFUSE... yes
checking for AVAHI... no
configure: error: Package requirements ( avahi-client >= 0.6.24 ) were not met:

No package 'avahi-client' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables AVAHI_CFLAGS
and AVAHI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

I have installed libavahi :
./scripts/feeds install  libavahi avahi-utils avahi-daemon avahi-dnsconfd

=> Found my mistake ! After installing with "feeds", you have to "make menuconfig" and put an "M" for new packages... before the compilation.

(Last edited by RuyBlas on 9 Jun 2013, 13:57)

@RuyBlas: I'm not familiar with the Asus + Shibby firmware, but I'm guessing that since you made your post you've encountered more trouble compiling forked-daapd.

I had a look at source.tar.gz, and I can see it needed some improvements. So I've made some changes and uploaded a new version. The new version links to a version of forked-daapd which has been patched for Remote 3 and ffmpeg 0.11.

When I compile, I just download the OpenWrt trunk source (instructions: https://dev.openwrt.org/wiki/GetSource), install required packages + forked-daapd, libavl, libantlr3c and libunistring. Then make menuconfig and select forked-daapd (everything else should select automatically). And then compile. Here's the complete list of the commands (some stuff commented out - note first packages should be installed in your native Linux, if you don't have them already): http://www.gyfgafguf.dk/openwrt/src/mk_build_env (assumes you unpack source.tar.gz in ~/OpenWrt/local)

Compiling works for me, but forked-daapd has a few bugs preventing me from really using it. The bugs are mentioned here: http://wiki.openwrt.org/inbox/howto/forked-daapd (1 & 2)

(Last edited by ejurgensen on 2 Jul 2013, 21:15)

Has anywone had a look @ https://www.flyn.org/projects/dmapd/ recently for OpenWrt? It might not be up-to-date, but it contains a lot of sweet funtionality.

And anyway, if there should be anyone out there that would like to have a look at an up-to-date implementation in Java, have a look at https://github.com/jkiddo/jolivia

dmapd looks quite promising, and it even appears to be actively maintained. There is even a Makefile. I could compile it without trouble, so that was good too. However, when I ran it, it just spewed lots of error messages, so I guess something needs some tweeking after all. Googling it, I couldn't find much about others running it.

forked-daapd is working better on OpenWrt now, with the exception of my m4a files. They push the CPU to 100% on my WNDR3700, and I can't figure out why.

Hi ejurgensen,

I was browsing your work (both on OpenWrt and for the Raspberry Pi) to catch up on this topic. I noticed you recently added support for non-encrypted streaming. It is my believe that all Airport and Apple TV devices support this non-encrypted streaming. This could help lower the (CPU) resource usage of forked-daapd. I have an old Airport express and it happily accepts non-encrypted streams. Because of this, I can stream ALAC files (old Airport does not support much else except PCM streams) almost directly from the file system. This keeps resource usage very low. The downside is, it will only work with TCP and not UDP (partly because of the large packets in standard ALAC files with 4096 frames per packet). The TCP support is not present on Apple TV devices. I do not own an Apple TV, so I have not been able to play around with it enough to be conclusive about the same kind of streaming on it. Again, I think Apple TV devices will allow streaming unencrypted data. With its direct support for AAC I assume you can stream AAC files also 'almost' directly from the file system to the Apple TV, keeping resource usage to a minimum. You mentioned somewhere that ALAC in forked-daapd take up a huge amount of CPU-cycles. My solution works with a low resource consumption because it does not perform any encryption and because it does not perform any audio decoding and encoding (that is all done by the Airport device itself). And a nice side effect is, that it does not require many external libraries.

I'm currently working on a small piece of software to do the streaming of my ALAC library for my WNDR3700. The software should be portable to other devices as well. I'll make the sources public once it is stable enough. Actually I have started this quite some time ago. Other things, like a great summer with lots of biking, stopped me from working on it. Now I'm getting back to it with the weather changing and a bit more time on my hands (I hope). If there is enough interest I might try to get my hands on an Apple TV and see if I can get it to work on it as well. Do not expect this to happen within the first few weeks. The old Airport express version should be finished for the end of the year though.

See also: http://erikonbike.blogspot.nl/

Hope this is useful info.

Cheers,
Erik

Hi mr. Bike! Wow, very interesting read. Seems we share the same interest. I always wanted to use just serve from my router, but I was never able to solve the CPU problem, so in the end I bought the Raspberry.

The idea that removing the encryption could solve the problem never occured to me, but when I get home I'll try straight away. forked-daapd does not encrypt when streaming to Apple TV, so it should be simple to test. My previous tests were always with Airport Express, so I never tried the other combination.

Disabling encryption towards Airport Express in forked-daapd would be very simple. I could make it a configurable option, just to be safe.

Making your own server sounds pretty ambitious! Are you on github, so I can follow your work?

I'm not on Github yet. Still a bit uncomfortable with the current code quality (rest assured I don't want to keep 'improving' it indefinitely).

Interested to hear/read what your experience is when disabling/removing the encryption.

Well, I just tested, and unfortunately removing encryption did not solve my CPU problems. I noticed that I only have problems with AAC-files, not with ALAC and MP3. So it seems like it would be a transcoding issue, but I'm pretty sure I disabled transcoding in my previous tests.

Encryption doesn't seem to consume much CPU. I measured with 'top' on my WNDR3700 streaming an ALAC: 12% when streaming to ATV, and 15% when streaming to Airport Express.

Hmmm... not sure what is happening then. My application actually only copies packets right out of the m4a file into a buffer it then sends out over a (TCP for now) network connection. So there is absolutely no handling of the data. Packet sizes (compressed, so different sizes per packet) are right in the m4a-file, so the application knows how much data to fetch. On my laptop right now (so not really fair comparison) it does not reach 1% CPU usage. I do not create large buffers or anything (it will run with very little memory available). The application scans the m4a file first to determine some necessary information like duration and position of packets within the file. It also keeps track of the largest packet size and a single buffer to hold this largest packet is then created and used repeatedly (so no more memory allocation after first scan). This largest packet is only a few kilobytes big (for ALAC, for AAC it will even be less). Streaming the audio to the Airport express is done in a second pass of the file.

I'm going to try and get my hands on an Apple TV device and see if I can do some tests. Will have to change and add some code to support UDP streaming though.

Will try to get back soon.

First of all, thanks for this effort to get forked-daapd on Openwrt. Awesome work! I have it up and running on my WDR4300 using a Barrier Breaker trunk build from a few days ago.

Everything seems to be working well. I am testing it out on a small 3 song database (just simple MP3s), and viewing the log file (with it set to 'spam' level) I can see that it appears to be going well. I've paired it with my iPad without issue.

The only thing is, I can't see any of my songs in the Remote app (any of the 3). What's odd however, is if I select "Movies" under the shared library it does in fact show those 3 songs with the duration of those songs accurately reported. They don't play of course, but I'm curious as to why 3 MP3s (one of which was an untouched Amazon purchase) would be scanned and showing up as a Movie by forked-daapd. If anyone is willing to look at my log file I'd love to get to the bottom of this. Thank you!

UPDATE: Here's the output of the log file that shows it failing to identify a simple MP3 as such.

[2013-11-02 09:35:18]   ffmpeg: mjpeg decode frame unused 0 bytes
[2013-11-02 09:35:18]     mdns: Successfully added mDNS services
[2013-11-02 10:48:48]   ffmpeg: max_analyze_duration 5000000 reached at 5015510
[2013-11-02 10:48:48]   ffmpeg: File position after avformat_find_stream_info() is 323884
[2013-11-02 10:48:48]     scan: File has 2 streams
[2013-11-02 10:48:48]     scan: File has video (stream 1)
[2013-11-02 10:48:48]     scan: Duration 216946 ms, bitrate 261 kbps
[2013-11-02 10:48:48]     scan: samplerate 44100, bps 16
[2013-11-02 10:48:48]     scan: Unknown codec 0x8 (video: yes), format mp3 ((null))
[2013-11-02 10:48:48]     scan: Picked up 0 tags from file metadata
[2013-11-02 10:48:48]     scan: Picked up 0 tags from video stream metadata
[2013-11-02 10:48:48]     scan: Picked up 0 tags with extra md_map
[2013-11-02 10:48:48]     scan: Picked up 10 tags from file metadata
[2013-11-02 10:48:48]     scan: Picked up 1 tags from video stream metadata
[2013-11-02 10:48:48]     scan: Picked up 11 tags with generic md_map, 11 tags total

And the portion of the db write that shows it saving it as an Unknown video file format.

'm4v', TRIM(NULL), TRIM(NULL), TRIM(NULL), TRIM(NULL), NULL, 261, 44100, 216946, 7102474, 2010, 1, 1, 1, 1, 0, 0, 0, 0, 0, 2, 'Unknown video file format', 1383414528, 1367344851, 0, 1383414528, 0, 0, 'mp4v',

UPDATE2:
I tried an .m4a AAC file and that works just fine. So that's encouraging. Looks like my issue is isolated to MP3 files. Maybe it's due to the ID3 tag version?

(Last edited by onlinespending on 2 Nov 2013, 22:19)

Well, .m4a files sort of play from my WDR4300. Looks like I'm falling victim to the high CPU usage issue. A song can play just fine for 5 seconds, before the CPU maxes out and it no longer is heard on the Airport Express. It still shows as playing in the Remote app, just no sound. I can even pause the song, and resume playing for just 5 seconds before the issue creeps up again.

Interestingly, if I play the same song from Itunes on my Macbook (under Shared Libraries), CPU usage on OpenWRT is 0%. I suppose this merely sends the file to Itunes where the decode is happening, as opposed to using an Airport Express which requires decoding on the router?

UPDATE: Well this sucks. Same issue with Ogg Vorbis files. Plays for 5 seconds before no sound. Also hitting 99% CPU usage.

UPDATE2: Ahh! Figured out why my MP3s were be detected as Video files by FFMPEG. It's the stupid embedded artwork. I removed the embedded artwork and surely enough it plays just fine and no more high CPU usage either. So that's good. But a lot of my music library already has embedded artwork. Anyway around this with forked-daapd? I'd rather keep the embedded artwork in there for other music players.

Looks like this embedded art issue with FFMPEG was also a problem with XMBC (https://github.com/xbmc/xbmc/pull/2905)

[rbp/omxplayer] Ignore video stream in audio filetypes …

Since the ffmpeg 1.2 merge, we fail to play audio file with artwork.
These show up as having a mjpeg video stream, with just one frame in.
We get stuck in buffering and don't play the audio.

As people expect the paplayer behaviour, we ignore the video stream for
audio filetypes, so the audio can play with visualision.

(Last edited by onlinespending on 3 Nov 2013, 00:20)

FYI, Apple updated their Remote app for iOS 7 a couple of days ago and fortunately everything still works.