As a new user of MediaTomb, I've been trying to find a way to make it provide my CD collection to the clients. The CDs are stored as the whole disc in a flac file and a corresponding cue sheet to describe the track layout and other meta data (e.g., track name, performer). Now I would like MT to read the cue sheet and to create an virtual track to the db from each track, and then provide the tracks transcoded to the client devices.
I assume that this kind of operation could be possible through import.js or playlist.js? Any suggestions how to try to implement this?
if the .cue sheet is a simple text file that references FLAC files, then you can parse it by adding your own playlist parser to the playlist.js script.
Have a look at http://mediatomb.cc/pages/scripting especially at the section that describes the playlist script, and of course also look at the playlist script itself as an example. The basic idea is that you can read the a file line by line and once you gathered all info you can createa a virtual item and add it to the database.
After some tinkering I managed to hack up something functional, but which apparently still has some issues. I would assume most of the problems stem from the situation that the whole album is contained in the one .flac file and the tracks are given with start and stop times. I am able to parse all of the metadata from the .cue file, but I'm not sure how to add the tracks to the db. Currently I create an "dummy" object with all of the metadata and with objectType OBJECT_TYPE_ITEM_INTERNAL_URL, and the file name contains the information of the track location in the actual file. (When using the flac command for decoding, the decoding range can be specified with in command line: "flac -d file.flac --skip=1:23.45 --until=3:45.67 -o output.wav", the range being 1:23.45-3:45.67 here.) So the object file name contains the --skip and --until parts, too. After that, I add the object using the addAudio() function.
The added tracks show up, e.g., in the web UI somewhat correctly, and closer inspection shows them and internal urls with the correct file name (containing the range) and the defined custom mimetype. The problem, however is how to MT to pass the url through a transcoder. Currently the files show in the UI as links to ip:port/content/serve/full_path_to_file_and_range. Clicking them produces a 404 and an error to the log: "ERROR: Serving directories is not enabled in configuration".
I tried to add the corresponding transcoder definition without any luck and assume that there might be something wrong earlier in the construct. For example, trying to assign any other objectType than INTERNAL_URL produces an error when trying to add the track: the system attempts to access the file, but since it contains the range definition, too, it fails.
Any words of wisdom to assist the addition to the finish line?
> After some tinkering I managed to hack up something functional, but which apparently still has some issues.
> I would assume most of the problems stem from the situation that the whole album is contained in the one .flac file
> and the tracks are given with start and stop times.
Oooh, I was not aware of that, I thought you already extracted the tracks...
> Currently I create an "dummy" object with all of the metadata and with objectType OBJECT_TYPE_ITEM_INTERNAL_URL,
> and the file name contains the information of the track location in the actual file.
> (When using the flac command for decoding, the decoding range can be specified with in command line:
> "flac -d file.flac --skip=1:23.45 --until=3:45.67 -o output.wav", the range being 1:23.45-3:45.67 here.)
> So the object file name contains the --skip and --until parts, too. After that, I add the object using the addAudio() function.
Hmmm.. crap :) I understand the problem. Internal URL will really be looking for a file, so using special names there will
not be possible.
Will do a somewhat ugly workaround which should nevertheless work :>
Use an OBJECT_TYPE_ITEM_EXTERNAL_URL, set the location to "http://whatever/params?skip=xxxx&until=xxxx&realfile=pathtofile", you get the idea, I think you will not even have to bother with URL encoding because you only want to parse this string with your transcoding script, so it does not have to be a valid URL, it's only important that it starts with http://
Set the mimetype to something funny, like "audio/parseflac".
Setup a transcoding profile that will handle your audio/parseflac mimetype.
Set <accept-url>yes</accept-url> so that we do not attempt to proxy the URL.
Now you only have to write a shell/perl/python/whatever script that will parse the string from the URL - your script will get "http://whatever/params?skip=xxxx&until=xxxx&realfile=pathtofile" as the first parameter. Using the parsed out data - like the location of the file on disk as well as the skip and until options you can then invoke the the flac program and write the output to the out filename that you get from MT (the output filename that MT will be reading from).
So basically, you were on the right path and there's not much that is missing.
Let me know if you have further questions.
Thanks for the tips, now it's working. The needed changes were actually quite small, as well as the amount of the final scripts that were needed for the implementation.
If someone else has an interest for the implemented functionality, I can provide the information somehow.
nice to hear that it worked out the way you wanted! Would be great if you could post everything in the Scripting section of our Wiki:
I am hoping that you are the person who wrote the "Importing Tracks From flac+cue CD Image" section of the scripting wiki. If so, I was hoping you could lend me a hand getting it to work. I previously asked my questions in a new topic here:
newbie needs help with the scripting wiki
I would be grateful if you could take a look and let me know if you can help or not.
Log in to post a comment.