Problem with .pls streams (BBC transcoding)

  • jjne

    jjne - 2012-05-07


    I have a number of old Netgear MP101 audio streamers which work well with MediaTomb. However I am experiencing difficulties with the BBC streams.

    These are not available in standard MP3 format, only AAC or WMA. When you click on the link you get a standard .pls file…

    (for BBC 6Music, for example, it's here:

    Within this are two streams, which change periodically, and therein lies the problem.

    I can get vlc to transcode the pls file from the command line; it parses the .pls file and works, as does the GUI version. However I have not been able to get vlc to transcode this pls file within MediaTomb; it doesn't even start, as hard as I try to force it lol.

    I took the code from another forum post:

    <profile name="audio-common" enabled="yes" type="external">
    <agent command="vlc" arguments="-I dummy %in --sout '#transcode{acodec=mp3,ab=192,samplerate=44100,cha nnels=2}:standard{access=file,mux=raw,dst=%out}'"/>
    <buffer size="14400000" chunk-size="512000" fill-size="120000"/>

    I suspect that if I could get this to work *at all* it would be the answer, as VLC can parse the pls files. However this code crashes the Netgear and the temp files are showing zero bytes at all times, regardless of whether I specify the pls file or the actual data stream.

    I can, however, get ffmpeg to do the same job:

          <profile name="audio2pcm" enabled="yes" type="external">
            <agent command="ffmpeg" arguments="-i %in -acodec pcm_s16be -ab 192k -ar 44100 -ac 2 -f s16be -y %out"/>
            <buffer size="1048576" chunk-size="131072" fill-size="262144"/>

    This works, and the Netgear will play the radio station. However it only works if I take the stream URL from within the .pls file. Unfortunately this means that the stream only works for an hour or so due to the way the BBC have implemented their side.

    Needless to say this is very annoying :) If anyone could point me in the right direction re either getting MediaTomb to pre-parse the data to ffmpeg, or indeed where the vlc attempt is going wrong, I'd be very grateful. I would then be able to sell off my two DAB radios and leave everything to these devices.

  • jjne

    jjne - 2012-05-07

    OK, I've managed to get VLC to transcode to PCM, with the same result as for FFMPEG.

    It would appear that the problem I'm having is with MediaTomb itself; VLC is quite happy to accept the .pls file but because MediaTomb is unable to parse it, it's shutting the buffer down.

    Here's the debug from MediaTomb of the attempt to access the pls file:

    2012-05-07 17:32:23   DEBUG: [../src/] upnp_callback(): start
    2012-05-07 17:32:23   DEBUG: [../src/] upnp_actions(): start
    2012-05-07 17:32:23   DEBUG: [../src/] process_action_request(): start
    2012-05-07 17:32:23   DEBUG: [../src/] upnp_action_Browse(): start
    2012-05-07 17:32:23   DEBUG: [../src/storage/] browse(): QUERY: SELECT "f"."id","f"."ref_id","f"."parent_id","f"."object_type","f"."upnp_class","f"."dc_title","f"."location","f"."location_hash","f"."metadata","f"."auxdata","f"."resources","f"."update_id","f"."mime_type","f"."flags","f"."track_number","f"."service_id","rf"."upnp_class","rf"."location","rf"."metadata","rf"."auxdata","rf"."resources","rf"."mime_type","rf"."service_id","as"."persistent" FROM "mt_cds_object" "f" LEFT JOIN "mt_cds_object" "rf" ON "f"."ref_id"="rf"."id" LEFT JOIN "mt_autoscan" "as" ON "as"."obj_id"="f"."id"  WHERE "f"."parent_id"=2 ORDER BY ("f"."object_type"=1) DESC, "f"."dc_title" LIMIT 9 OFFSET 9
    2012-05-07 17:32:23   DEBUG: [../src/] upnp_action_Browse(): end
    2012-05-07 17:32:23   DEBUG: [../src/] process_action_request(): ContentDirectoryService::process_action_request: end
    2012-05-07 17:32:23   DEBUG: [../src/] upnp_callback(): returning 0
    2012-05-07 17:32:27   DEBUG: [../src/] upnp_callback(): start
    2012-05-07 17:32:27   DEBUG: [../src/] upnp_actions(): start
    2012-05-07 17:32:27   DEBUG: [../src/] process_action_request(): start
    2012-05-07 17:32:27   DEBUG: [../src/] upnp_action_Browse(): start
    2012-05-07 17:32:27   DEBUG: [../src/storage/] browse(): QUERY: SELECT "f"."id","f"."ref_id","f"."parent_id","f"."object_type","f"."upnp_class","f"."dc_title","f"."location","f"."location_hash","f"."metadata","f"."auxdata","f"."resources","f"."update_id","f"."mime_type","f"."flags","f"."track_number","f"."service_id","rf"."upnp_class","rf"."location","rf"."metadata","rf"."auxdata","rf"."resources","rf"."mime_type","rf"."service_id","as"."persistent" FROM "mt_cds_object" "f" LEFT JOIN "mt_cds_object" "rf" ON "f"."ref_id"="rf"."id" LEFT JOIN "mt_autoscan" "as" ON "as"."obj_id"="f"."id"  WHERE "f"."parent_id"=2 ORDER BY ("f"."object_type"=1) DESC, "f"."dc_title" LIMIT 1 OFFSET 12
    2012-05-07 17:32:27   DEBUG: [../src/] upnp_action_Browse(): end
    2012-05-07 17:32:27   DEBUG: [../src/] process_action_request(): ContentDirectoryService::process_action_request: end
    2012-05-07 17:32:27   DEBUG: [../src/] upnp_callback(): returning 0
    2012-05-07 17:32:27   DEBUG: [../src/] create_request_handler(): Filename: /content/online/object_id/6/res_id/none/pr_name/audio2pcmvlc/tr/1, Path: (null)
    2012-05-07 17:32:27   DEBUG: [../src/] open(): start
    2012-05-07 17:32:27   DEBUG: [../src/] open(): full url (filename): /content/online/object_id/6/res_id/none/pr_name/audio2pcmvlc/tr/1, parameters: object_id/6/res_id/none/pr_name/audio2pcmvlc/tr/1
    2012-05-07 17:32:27   DEBUG: [../src/] open(): Online content url:
    2012-05-07 17:32:27   DEBUG: [../src/transcoding/] open(): start
    2012-05-07 17:32:27   DEBUG: [../src/] normalizePath(): Normalizing path: /tmp//mt_transcode_3177DW
    2012-05-07 17:32:27   DEBUG: [../src/transcoding/] open(): creating fifo: /tmp/mt_transcode_3177DW
    2012-05-07 17:32:27    INFO: Arguments: -I dummy -vvv %in --sout=#transcode{acodec=s16b,channels=2,ab=128,samplerate=44100}:standard{access=file,mux=raw,dst=%out}'
    2012-05-07 17:32:27   DEBUG: [../src/] ProcessExecutor(): Launched process vlc, pid: 20014
    2012-05-07 17:32:27   DEBUG: [../src/] ProcessExecutor(): Launching process: vlc
    2012-05-07 17:32:27   DEBUG: [../src/] registerSingleton(): registering new singleton... - 8 -> 9
    2012-05-07 17:32:27   DEBUG: [../src/] staticThreadProc(): starting buffer thread... thread: 749082368
    2012-05-07 17:32:28   DEBUG: [../src/] staticThreadProc(): buffer thread shut down. thread: 749082368
    2012-05-07 17:32:28   DEBUG: [../src/] close(): terminating process, closing /tmp/mt_transcode_3177DW
    2012-05-07 17:32:28   DEBUG: [../src/] kill_proc(): KILLING TERM PID: 20014
    2012-05-07 17:32:29   DEBUG: [../src/] close(): terminating process, closing /tmp/mt_transcode_3177DW

    If I hard-code the .pls into the VLC configuration, it still does not work. I suspect this is due to the FIFO pipe that is set up between MediaTomb and VLC; VLC can happily parse the file, and transcode, but because the pipe is not being established by VLC MediaTomb tears it down.

    So, I'm back at square one. MediaTomb seems incapable of dynamically parsing pls files that change over time.

    The next step, I would have thought would be to set up VLC externally, use it to receive and transcode the pls first, then pass this to MediaTomb which could in turn send it on its way to the streamer. But I'm left with a chicken-and-egg problem - how to get MediaTomb to start VLC in order to do this, when it's MediaTomb itself that starts VLC after it's opened its output pipe?

  • jjne

    jjne - 2012-05-14

    Come on guys, a little help would be appreciated here :)

    I have attempted to use a script to start the VLC transcode, then use dd to 'dummy-transcode' the data to the Netgear. No go.

    The VLC does start transcoding, but I suspect that because the only way I can see this working is to pass the VLC stream as the HTTP string in the first place, I am trying to get Mediatomb to 'transcode' a stream that doesn't exist until *after* the transcode is called. Hence it doesn't do anything.

    Here's my attempt:

    <profile name="audio2pcm-radio6" enabled="yes" type="external">
            <agent command="/opt/" arguments="%in %out 8086"/>
            <buffer size="600000" chunk-size="10000" fill-size="32000"/>

    vlc -I dummy -vvv $3 --sout ''#transcode{acodec=mp3,channels=2,ab=320,samplerate=44100}:standard{access=http,mux=raw,dst=$4}''
    dd if=$1 of=$2

    Passing to MediaTomb.

    As I say, I believe the problem is that doesn't exist until after the shell script is called.

    I can run a 'transcode' with just the dd line when the transcoded MP3 stream is already running and the music plays. This is no good though as it requires the stream to be running before it's called by the box. Not ideal.

    I suppose I now have three options:

    1) Stream the required BBC stations permanently from a DVB card. This would work, but it's wasteful in terms of resources and the sound quality from DVB is not as good as AAC.

    2) Manually set off a VLC transcode before keying in a station: kind of defeats the object of having a media streamer really.

    3) Buy another box: but surely that can't be the answer?

    4) Parse the pls file in HTTP: Requires javascript or similar to be running on MediaTomb and I don't think it does.

    5) Run a CRON job that downloads and parse the pls files and dumps the result into an HTTP redirect page to be called by MediaTomb: would work, but is a total faff and the radio stations would still fail once an hour.

  • cojms1

    cojms1 - 2012-08-31

    I know this thread is a little old but I think I have solution for you now (I needed to get this working for myself)
    This is what I have done…

    Create an External Link (URL) item in the Web Interface

    Modify the config.xml with the following…

    In the mimetype-profile-mappings section…

    <transcode mimetype="audio/x-bbcradio" using="bbc2pcm"/>

    In the transcoding profiles section…

     <profile name="bbc2pcm" enabled="yes" type="external">
            <agent command="/scripts/" arguments="-f bbcradio_playlist -i %in -o %out"/>
            <buffer size="1048576" chunk-size="4096" fill-size="1024"/>

    The is a bash script similar to that on the mediatomb wiki.  Mine is most definitely a work in progress but works for transcoding Internet Radio for my PS3.  The script is below…

    transcode_to_pcm() {
      exec /usr/bin/ffmpeg -i "$1" -ac 2 -ar 44100 -y -f s16be "$2"
    bbcradio_playlist() {
      wget -q -O $OUT_FILE $INPUT
      LINE=`grep -e $FIND_STR $OUT_FILE`
      rm $OUT_FILE
      transcode_to_pcm $RADIO_URL $2
    while [ "$#" -gt "0" ]
      case "$1" in
            shift; shift;
            shift; shift;
            shift; shift;
            echo "${USAGE}"
            exit 1

    Hope this helps.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks