How do I setup Twonky to serve FLACs

Other OS or NAS discussions
Post Reply
Eddy5
Posts: 6
Joined: Thu Nov 15, 2007 7:02 pm

How do I setup Twonky to serve FLACs

Post by Eddy5 » Thu Nov 15, 2007 7:07 pm

Hi,

I'm trying to get Twonky to serve FLACs to a Pinnacle/Roku Soundbridge M1001 and an XBox 360 from my NSLU2. Both give the same problem of being able to browse the albums and songs, but all are listed with an 'x' before them (Red X in a box on the 360) meaning they can't be played.
MP3s work fine on both, as do pics and vids to the 360.
Do I need to install a transcoder. (I'm running v4.4.2 for the NSLU2)

lutipold
Posts: 6
Joined: Sat Feb 04, 2006 7:01 pm

FLAC on NSLU (Debian)

Post by lutipold » Fri Nov 16, 2007 3:27 pm

I have a Linksys NSLU with Debian and TwVi 4.4.2, and am experiencing problems with FLAC cgi-bin setup.
After downloading the cgi-flac source code, I manage to compile it without any problems (make) (Yes, I changed 2000 seconds to 2 seconds in the source code). I copied the cgi-flac executable to the /local/twonkyvision/cgi-bin directory on my NSLU. I also located a flac-wav.desc file in the Linux cgi-flac binary download, which I copied to the cgi-bin directory.

Content of the flac-wav.desc file

# transcode audio
#(c) 2006 by TwonkyVision
exec: cgi-flac
# parameters
from=audio/x-flac
to=audio/x-wav
source=$source
cache=$cache

I used apt-get to install the flac executable.

Then I restarted the twonky-server. When I use the web based media browser, the flac music files are presented as “flac” - not wav. :(

lutipold
Posts: 6
Joined: Sat Feb 04, 2006 7:01 pm

FLAC from Debian/NSLU2

Post by lutipold » Sat Nov 17, 2007 3:46 pm

I made some progress today :-)

First I tried to get the cgi-flac executable to run from the shell prompt. I put a test file in /tmp, and executed the following command:

/local/twonkyvision/cgi-bin/cgi-flac "?source=/tmp/test.flac&from=audio/x-flac&to=audio/x-wav&cache=/tmp"

The program returned an error message, indicating that the flac executable was missing. The cgi-flac.c must be modified so it can locate /usr/bin/flac. I went around this issue, and copied the flac executable to the cgi-bin directory. Probably not a good idea if you are concerned about security.

But still the Twonky web interface was presenting files in flac format. I checked my PS3, and "Incompatible data" was all over the place. But from Windows Media Player i managed to play the flac files. Success!
I actually got the NSLU to decode flacs to wav!!! Some preliminary test show that the unit has the needed juice to handle this conversion.

PS3 - as you all now – got some issues with receiving streamed wav, even if it plays wav-files from USB-memory.

obnoxiousduck
Posts: 4
Joined: Tue Nov 13, 2007 5:57 pm

Post by obnoxiousduck » Sat Nov 17, 2007 5:35 pm

I am also unable to transcode FLAC -> WAV to my Xbox 360. I tried cgi-flac at the command line and it created a wav that plays with no problem.

The file and all the meta tags show up in the dashboard, but the song does not play

obnoxiousduck
Posts: 4
Joined: Tue Nov 13, 2007 5:57 pm

Post by obnoxiousduck » Sat Nov 17, 2007 5:38 pm

By the way I am running the latest Twonky on Linux (Centos 5)

lutipold
Posts: 6
Joined: Sat Feb 04, 2006 7:01 pm

Xbox 360

Post by lutipold » Sat Nov 17, 2007 6:19 pm

I tried my Xbox 360, and got the same disappointing results as obnoxiousduck. I have also tried to modify the clients.db for the 360:

MT:flac audio/flac
change to:
MT:flac audio/x-flac

This didn't do the trick for me. (feel free to try this as well).

Is it necessary to restart the Twonky server to source the clients.db?

obnoxiousduck
Posts: 4
Joined: Tue Nov 13, 2007 5:57 pm

response I got from Twonky support

Post by obnoxiousduck » Mon Nov 19, 2007 4:08 pm

sorry - we do not know how to transcode FLAC for the XBOX 360.
The XBOX is a bit picky about content (and content lenght)

Sorry
The TwonkyMedia Team

mojjsan
Posts: 6
Joined: Wed Nov 21, 2007 7:36 pm

Post by mojjsan » Wed Nov 21, 2007 8:29 pm

I'm also trying to transcode flac with twonky. If it doesn't work there would not be any idea for me to buy it.
I have a DNA-323 and has installed a cross-compiler on my linux-dist using the guide: http://wiki.dns323.info/howto:crosscompile
The cgi-flac compiles with no problems but when I test it I get: "execl: No such file or directory". What could be wrong ?

mojjsan
Posts: 6
Joined: Wed Nov 21, 2007 7:36 pm

Post by mojjsan » Thu Nov 22, 2007 1:35 pm

Well, it turned out that one need flac-binaries as well :oops: :wink:

I downloaded flac-1.2.1 and compiled it and it kind of worked. It produced the following error:
../libFLAC/.libs/libFLAC.so: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[2]: *** [libFLAC++.la] Error 1
but it produced libflac.so and flac binaries so I put them on DNS-323 and tried:
/mnt/HD_a2/twonky/cgi-bin # ./cgi-flac "?source=1.flac&from=audio/x-flac&to=audio/x-wav&cache=/tmp"
QUERY_STRING ?source=1.flac&from=audio/x-flac&to=audio/x-wav&cache=/tmp
Location: /tmp/1.flac.wav
And there it was, a empty wav file in /tmp. So I guess its back to square one and try compile it without errors.

mojjsan
Posts: 6
Joined: Wed Nov 21, 2007 7:36 pm

Post by mojjsan » Sun Nov 25, 2007 3:21 pm

It works !!!! :mrgreen:

I compiled flac-1.1.2 with ogg-support and used all lib* created. I then compiled flac-1.2.1 and copied libFLAC.so.8.2.0 to lib/ as well as symlink libFLAC.so.8 to it. I then copied the contents of lib/ from the libogg-1.1.3 compilaton to the same lib as the libflac:s. The compiled cgi-flac and flac-wav.desc which lutipold pointed to were copied to twonky/cgi-bin.

I then started the Teac WAP-5000 and listened to some cd:s :)

Eddy5
Posts: 6
Joined: Thu Nov 15, 2007 7:02 pm

Post by Eddy5 » Sat Dec 08, 2007 11:56 am

Does anyone have these files pre-compiled for the NSLU2 as I can't seem to compile them (I've no real idea how to do it anyway, and the tutorials for compiling on the elsewhere web don't seem to work for me)

The Highlander
Posts: 9
Joined: Fri Sep 08, 2006 5:45 pm

Post by The Highlander » Tue Dec 25, 2007 3:59 pm

@Eddy5
You can install Flac by using ipkg on your slug.
The current version is 1.2.1, but the links are OK.
I can send the cgi-files by E-Mail if you want.

But it seems that the cgi-bin solution does not transcode on the fly.
And therefore you have to wait very long before the stream starts.
The NSLU2 is far too slow for this kind of transcoding :(

Can anyone confirm this or did I make a mistake in my configuration?

The Highlander
Posts: 9
Joined: Fri Sep 08, 2006 5:45 pm

Post by The Highlander » Tue Dec 25, 2007 4:45 pm

Just found another thread:

http://www.twonkyforum.com/viewtopic.ph ... light=flac

animaal posted to reduce the sleeptime from 2000 to 2 ms.
This was the reason for a timeout, so I believed the files aren't
transcoded on the fly! Now it seems to work on a NSLU2 :D

One last problem I have is:
On a Roku client I don't get a the playtime of a song and
therefore the progress bar is empty :(

Any hints of how to fix this issue?

Edit:
All other metadata except artist/song/album is missing too.
The transcoded files in the cache-folder aren't deleted, that really is a problem :!:

Valley
Posts: 5
Joined: Wed Jan 02, 2008 12:30 am

Post by Valley » Wed Jan 02, 2008 2:00 pm

[quote="The Highlander"]All other metadata except artist/song/album is missing too.
The transcoded files in the cache-folder aren't deleted, that really is a problem :!:[/quote]

Thanks to "The Highlander", I was able to install the Flac plugin for the NSLU2. I'm running a NSLU2 (modded=doubled MHz) with the latest Unslung (6.8beta) & the latest Twonkyvision 4.4.3.1, serving to a Noxon 2 Audio (latest FW, too). USB 2.5" HD (w/o external power) on port 2.

A couple of points to mention:

twonkyvision/twonkymedia.db/cache has the cached files even when playing for that file has ended. Even a Twonky-Server restart doesn't clean the cache.

The cache folder size can be limited in Twonkyvision's configuration settings (extended settings, found under last option "various" - or similar, I'm using the German language setting - v4.4.3.1). I limited my folder cache size to 563200 KBytes (roughly 0.5 GB) = or 5-10 stereo Flac files of around 3 min length. No reaction, none of the older files got deleted or overwritten. Even a limit to 100 MBytes (102400 KBytes) didn't work. Will report this as en error.

Playing / running time shows correctly on the Noxon 2. Skipping forward is okay. Pause / Resume works, too.

I'm using the Noxon 2 Audio with digital out (SPDIF optical) to my amplifier. FLAC Stereo is working, but WAV (or FLAC) multichannel files that have DTS or Dolby AC3 embedded sound don't play thru the Noxon's digital out.
Looks like you have to use another LAN device for such files. In case sb cares, the FLAC webpage lists a few LAN devices (like amplifiers etc.) with FLAC support - which one supports WAV DTS / DOLBY AC3 thru digital out isn't mentioned.

"The Highlander" also mentioned to set the correct rights for the files in the cgi-bin folder:
chmod 755 cgi-flac
chmod 644 flac-wav.desc

Cache folder problem with limit size not recognized confirmed for version 4.4 and version 4.4.3RC4 on uNSLUng 6.8 when playing FLAC.

Steve
Last edited by Valley on Wed Jan 02, 2008 11:54 pm, edited 1 time in total.

The Highlander
Posts: 9
Joined: Fri Sep 08, 2006 5:45 pm

Post by The Highlander » Wed Jan 02, 2008 2:15 pm

It should be as follows :wink:
chmod 755 cgi-flac
chmod 644 flac-wav.desc

Valley
Posts: 5
Joined: Wed Jan 02, 2008 12:30 am

Post by Valley » Thu Jan 10, 2008 10:38 am

update on my previous note to keep this thread running:
neither the values of "0" or "-1" had any effect to limit the cache size on the cache folder on my NSLU2.

The temp. solution at the moment is to clear all files in the cache folder during start-up of twonky when the NSLU2 has been restarted.

I updated the
"S99twonkyvision"
script in opt\etc\init.d
to include the line

rm -rf /share/flash/data/twonkyvision/twonkymedia.db/cache/*

In my opinion, it would be better to customize the
cgi-flac.c program itself.

Even the caching behaviour isn't great, in my opinion, so it makes no sense, IMHO, to keep any of the converted .WAV files.

When a flac file is called, the script starts to convert it to wav and starts playing that file from the beginning, even when it hasn't finished converting the whole .FLAC file to a .WAV file yet. When you press "SKIP next" now on your remote control (or in your player), Twonky cancels the converting process and starts a new one. So the first converted WAV file is still unfinished in the cache folder. Now, when you try to play any of the previous converted files AGAIN, it looks first in the cache folder for that file. If it finds one fitting file there, it starts playing this - EVEN when the WAV files hasn't been finished previously. So playing an unfinished file makes it ending abruptly, not playing to the very end - as expected.
So why keep any of the converted WAV files in the cache folder, if you can't be sure they are okay??? Nonsense, IMHO.
Best would be to delete them before converting/playing the next one.

So adding something like (in c language, sure)

rm -f *.wav (or rm *.wav) (for all files in the cache folder)

at the beginning of cgi-flac.c file would be okay and solve this problem.

Any ideas ???

Anybody who can change the cgi-flac.c script accordingly and compile it again for the NSLU?

Here's another example where sb changed the script to his needs:

[url]http://www.twonkyforum.com/viewtopic.php?p=15476[/url]

BTW, I haven't tested the latest 4.4.beta from January, but the changelog hasn't mentioned any changes for the cache folder behaviour.
Last edited by Valley on Fri Jan 11, 2008 7:51 pm, edited 4 times in total.

The Highlander
Posts: 9
Joined: Fri Sep 08, 2006 5:45 pm

Post by The Highlander » Fri Jan 11, 2008 6:09 pm

I followed Valleys suggestion and I tried to delete the file after decoding:

Code: Select all

switch (pid) {
	    case -1:
			perror("fork");
			break;
	    case 0:
			execl ("/opt/bin/flac", "/opt/bin/flac", "--silent", 
                        "--decode", source, "-o", outfile, NULL);
			perror("execl");
			_exit(0); // should never been reached
	    default:
			sleep(2);
			cat_file(outfile,1/*TRUE*/);
			waitpid(pid,NULL,0);
			unlink(outfile); // <-- DELETE FILE AFTER FLAC FINISHED
			free(outfile);
			return 0;
			break;
The thing is that this should not work because I delete the file
immidiately after finishing decoding by flac.

But for some reason it is working for me :D
Has anyboby an idea why it is working?

Because some people send me a PM, here is the link to this version:

http://www.dbrinkmeier.de/Tools/cgi-flac

P.S.:
No guarantee for working....

Valley
Posts: 5
Joined: Wed Jan 02, 2008 12:30 am

Post by Valley » Fri Jan 11, 2008 8:44 pm

Thanks, great progress.

Anyway, there's still a slight problem with skipping forwards (or backwards).
Let me describe the behaviour on my Noxon.
When starting playing, the corresponding .wav file is created and exists in the cache folder for appr. 30 seconds. After this, it disappears (gets deleted, I assume).
[N.B. The first file played after (re)start of Twonky even doesn't show up as .wav file, however - don't know why this happens - but it plays okay.]
So, if you press skip during the first 30 second into a song, the converted .wav (part) of that file didn't get deleted, even after the next file has started playing.
So, I recommend either:
a) that you start skipping not before you've reached this time limit of appr. 30 sec.
b) the cg-flac.c program gets another program line somewhere at the top where it deletes all *.wav files that exist in the cache folder, if this is possible.

Steve
Last edited by Valley on Fri Jan 11, 2008 9:44 pm, edited 1 time in total.

The Highlander
Posts: 9
Joined: Fri Sep 08, 2006 5:45 pm

Post by The Highlander » Fri Jan 11, 2008 8:57 pm

Valley wrote: b) the cg-flac.c program gets another program line somewhere at the top where it deletes all *.wav files that exist in the cache folder, if this is possible.
It is not possible to delete all (wave) files in the cache folder before playing a new file, because you will also delete files that are in use by an other user or media player or application!
Valley wrote: When starting playing, the corresponding .wav file is created and exists in the cache folder for appr. 30 seconds. After this, it disappears (gets deleted, I assume).
That behaviour is intended by my solution. Decoding the flac files doesn't take as long as playing the same file. Otherwise transcoding would be impossible.

SumnerBoy
Posts: 9
Joined: Fri Feb 22, 2008 9:03 am

Re: How do I setup Twonky to serve FLACs

Post by SumnerBoy » Tue Feb 26, 2008 3:20 am

Hi there - I am running Twonky on Ubuntu 7.10 Server Edition and am getting the same problem when trying to transcode FLAC to my XBox 360. I have downloaded and installed the flac to wav cgi plugin. This included a flac binary which is installed to /usr/local/TwonkyVision/cgi-bin along with the cgi-flac plugin and flac-wav.desc config file.

When I try to play a FLAC from my Xbox360 I still get the red cross next to it and nothing happens.

I noticed that the /usr/local/TwonkyVision path is owned by '11560:5513', see below...

Code: Select all

drwxrwx--- 6 11560 5513 4096 2008-02-25 14:08 TwonkyVision
Is this right - will it have an effect on things?

Any help would be greatly appreciated! About half my music collection is in FLAC format so it would be nice to be able to play these files as well.

The Highlander
Posts: 9
Joined: Fri Sep 08, 2006 5:45 pm

Re: How do I setup Twonky to serve FLACs

Post by The Highlander » Tue Feb 26, 2008 6:49 am

SumnerBoy wrote: I have downloaded and installed the flac to wav cgi plugin.
Hello Sumner Boy.
From where did you download?
This thread was about transcoding from a NSLU2....
The files above will not work for other processors.

SumnerBoy
Posts: 9
Joined: Fri Feb 22, 2008 9:03 am

Re: How do I setup Twonky to serve FLACs

Post by SumnerBoy » Tue Feb 26, 2008 8:13 am

You know what - I am not actually sure. I have read that many posts and threads on this topic I can't exactly remember where I got it from. The file name is flac-i386_341_225.zip. Are you able to tell if this is the wrong/correct one? Are there libraries for Ubuntu 7.10 that I can get from somewhere else? Or am I outta luck?

Thanks for taking an interest!

murrayfleming
Posts: 30
Joined: Sat Feb 11, 2006 1:44 pm

Re: How do I setup Twonky to serve FLACs

Post by murrayfleming » Tue Feb 26, 2008 9:30 am

It looks like the flac-i386_341_225.zip file comes from the Twonky Addons page

This works on a PC running openSUSE, so I'm guessing that it should also work on Ubuntu.

You can test the plugin by, as described by lutipold earlier in this thread, as below:

Place a test.flac file in /tmp and (as root?) execute the following command:

/usr/local/twonkyvision/cgi-bin/cgi-flac "?source=/tmp/test.flac&from=audio/x-flac&to=audio/x-wav&cache=/tmp"

This should produce a test.wav file in /tmp

SumnerBoy
Posts: 9
Joined: Fri Feb 22, 2008 9:03 am

Re: How do I setup Twonky to serve FLACs

Post by SumnerBoy » Tue Feb 26, 2008 9:38 am

Ok - tried that and it did indeed generate a wav file in /tmp. I guess that means the addon is working. Is there some way to work out why my TwonkyServer is activating the plugin when my XBox360 accesses FLAC files?

murrayfleming
Posts: 30
Joined: Sat Feb 11, 2006 1:44 pm

Re: How do I setup Twonky to serve FLACs

Post by murrayfleming » Tue Feb 26, 2008 11:39 am

Well at least that works :)

If you have changed the clients.db file to read "MT:flac audio/x-flac" instead of "MT:flac audio/flac" for the XBox entry, and have stoped and restarted Twonky (or just rebooted), then Twonky should now magically make your your flac files "appear" to be wav files. If the Xbox can play wav files then this should allow you to select these files to be played, and the plugin will transcode them.

:?: If you put a wav file in your music directory, can you play it on the Xbox?

SumnerBoy
Posts: 9
Joined: Fri Feb 22, 2008 9:03 am

Re: How do I setup Twonky to serve FLACs

Post by SumnerBoy » Tue Feb 26, 2008 9:16 pm

I just copied the WAV file generated by that test script I ran earlier into my music folder, refreshed the TwonkyServer, and tried to play the file through my XBox360 - but no luck. I just get the red cross next to the file name and nothing happens when I click play.

I have my XBox hooked up to XBox Live so it should have any updates applied - is there a way to check?

Thanks for your interest!

SumnerBoy
Posts: 9
Joined: Fri Feb 22, 2008 9:03 am

Re: How do I setup Twonky to serve FLACs

Post by SumnerBoy » Tue Feb 26, 2008 9:19 pm

BTW - I have updated my clients.db file with audio/x-flac etc. When a file is listed in the XBox is there any way to know what type it thinks it is? Currently it is just showing up the track titles - i.e. I don't know if it is seeing them as FLAC or WAV.

murrayfleming
Posts: 30
Joined: Sat Feb 11, 2006 1:44 pm

Re: How do I setup Twonky to serve FLACs

Post by murrayfleming » Wed Feb 27, 2008 12:20 pm

Did the wav file you placed in the Music directory have a different name to any of your flac files? If it did then Twonky must be telling the Xbox that this is a wav file. If the Xbox thinks that it can't play it, then all I can deduce is that your Xbox can't handle wav files. :(

This thread seems to confirm this, although it is a year old.

I'd make sure that you are running the latest version of Twonky (4.4.4), and whatever the latest Xbox update is.

As I don't have an XBox I'm not sure if I can be of any more help. There is a dedicated XBox section on this forum. You should probably post there and see if anybody knows how to get wav files playing on the Xbox, or email Twonky support. I wouldn't bother mentioning transcoding as that would just confuse the issue. Also Twonky don't support trancoding, so if you mention it they probably won't reply....

One final idea, as the thread I referenced mentioned, might be to transcode from flac to mp3. I'll have a play around with this, and post in the Xbox section if I get anywhere.

We'd better close this thread here in case the NAS guys get upset. :wink: Although we did establish that the flac plugin doesn't only work on a NAS, and that the red cross beside flac/wav files on an Xbox (discussed by other people in ths thread) seems to be a Xbox issue. So I think we added some value. :)

SumnerBoy
Posts: 9
Joined: Fri Feb 22, 2008 9:03 am

Re: How do I setup Twonky to serve FLACs

Post by SumnerBoy » Wed Feb 27, 2008 8:18 pm

Fair enough - and thanks again. Will keep an eye on the XBox forum and post some questions about playing WAVs.

The Highlander
Posts: 9
Joined: Fri Sep 08, 2006 5:45 pm

Re: How do I setup Twonky to serve FLACs

Post by The Highlander » Sat Mar 08, 2008 10:30 am

In the latest version 4.4.4 Roku Soundbridges are no longer recognized as clients.
So the clients.db can be changed for flac support, but it will not take effect because the client
can't be linked to the correct settings!

Valley
Posts: 5
Joined: Wed Jan 02, 2008 12:30 am

Re: How do I setup Twonky to serve FLACs

Post by Valley » Thu Aug 28, 2008 2:03 pm

As of today. Twonky version 4.4.6 (20080730) works okay with FLAC using the NSLU2 + Noxon plus the cgi-flac file linked above and and the settings (chmod) discussed here.

attn: Highlander, have you compiled the updated cgi-flac file with the automatic delete after transcoding and can you place a link to it somewhere, because the file you linked/supplied above just shows an old file dated 11. Jan. 2008 ??? Thanks ...

Post Reply