Problem with .pls streams (BBC transcoding)

Help
jjne
2012-05-07
2013-05-30
  • jjne

    jjne - 2012-05-07

    Hi,

    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: http://www.bbc.co.uk/radio/listen/live/r6_aaclca.pls)

    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">
    <mimetype>audio/mpeg</mimetype>
    <use-chunked-encoding>no</use-chunked-encoding>
    <accept-url>yes</accept-url>
    <first-resource>yes</first-resource>
    <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"/>
    </profile>
    

    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">
            <mimetype>audio/L16</mimetype>
            <accept-url>no</accept-url>
            <first-resource>yes</first-resource>
            <hide-original-resource>yes</hide-original-resource>
            <accept-ogg-theora>no</accept-ogg-theora>
            <sample-frequency>44100</sample-frequency>
            <audio-channels>2</audio-channels>
            <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"/>
          </profile>
    

    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/server.cc:354] upnp_callback(): start
    2012-05-07 17:32:23   DEBUG: [../src/server.cc:436] upnp_actions(): start
    2012-05-07 17:32:23   DEBUG: [../src/upnp_cds_actions.cc:182] process_action_request(): start
    2012-05-07 17:32:23   DEBUG: [../src/upnp_cds_actions.cc:45] upnp_action_Browse(): start
    2012-05-07 17:32:23   DEBUG: [../src/storage/sql_storage.cc:786] 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_cds_actions.cc:138] upnp_action_Browse(): end
    2012-05-07 17:32:23   DEBUG: [../src/upnp_cds_actions.cc:209] process_action_request(): ContentDirectoryService::process_action_request: end
    2012-05-07 17:32:23   DEBUG: [../src/server.cc:415] upnp_callback(): returning 0
    2012-05-07 17:32:27   DEBUG: [../src/server.cc:354] upnp_callback(): start
    2012-05-07 17:32:27   DEBUG: [../src/server.cc:436] upnp_actions(): start
    2012-05-07 17:32:27   DEBUG: [../src/upnp_cds_actions.cc:182] process_action_request(): start
    2012-05-07 17:32:27   DEBUG: [../src/upnp_cds_actions.cc:45] upnp_action_Browse(): start
    2012-05-07 17:32:27   DEBUG: [../src/storage/sql_storage.cc:786] 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_cds_actions.cc:138] upnp_action_Browse(): end
    2012-05-07 17:32:27   DEBUG: [../src/upnp_cds_actions.cc:209] process_action_request(): ContentDirectoryService::process_action_request: end
    2012-05-07 17:32:27   DEBUG: [../src/server.cc:415] upnp_callback(): returning 0
    2012-05-07 17:32:27   DEBUG: [../src/web_callbacks.cc:72] 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/url_request_handler.cc:182] open(): start
    2012-05-07 17:32:27   DEBUG: [../src/url_request_handler.cc:195] 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/url_request_handler.cc:231] open(): Online content url: http://www.bbc.co.uk/radio/listen/live/r6_aaclca.pls
    2012-05-07 17:32:27   DEBUG: [../src/transcoding/transcode_ext_handler.cc:90] open(): start
    2012-05-07 17:32:27   DEBUG: [../src/tools.cc:1039] normalizePath(): Normalizing path: /tmp//mt_transcode_3177DW
    2012-05-07 17:32:27   DEBUG: [../src/transcoding/transcode_ext_handler.cc:315] 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/process_executor.cc:77] ProcessExecutor(): Launched process vlc, pid: 20014
    2012-05-07 17:32:27   DEBUG: [../src/process_executor.cc:71] ProcessExecutor(): Launching process: vlc
    2012-05-07 17:32:27   DEBUG: [../src/singleton.cc:73] registerSingleton(): registering new singleton... - 8 -> 9
    2012-05-07 17:32:27   DEBUG: [../src/io_handler_buffer_helper.cc:224] staticThreadProc(): starting buffer thread... thread: 749082368
    2012-05-07 17:32:28   DEBUG: [../src/io_handler_buffer_helper.cc:227] staticThreadProc(): buffer thread shut down. thread: 749082368
    2012-05-07 17:32:28   DEBUG: [../src/process_io_handler.cc:438] close(): terminating process, closing /tmp/mt_transcode_3177DW
    2012-05-07 17:32:28   DEBUG: [../src/process.cc:151] kill_proc(): KILLING TERM PID: 20014
    2012-05-07 17:32:29   DEBUG: [../src/process_io_handler.cc:438] 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">
            <mimetype>audio/L16</mimetype>
            <accept-url>yes</accept-url>
            <first-resource>yes</first-resource>
            <hide-original-resource>yes</hide-original-resource>
            <accept-ogg-theora>no</accept-ogg-theora>
            <sample-frequency>44100</sample-frequency>
            <audio-channels>2</audio-channels>
            <accept-url>yes</accept-url>
            <agent command="/opt/test.sh" arguments="%in %out http://www.bbc.co.uk/radio/listen/live/r6_aaclca.pls 8086"/>
            <buffer size="600000" chunk-size="10000" fill-size="32000"/>
          </profile>
    

    test.sh:

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

    Passing http://192.168.255.101:8086 to MediaTomb.

    As I say, I believe the problem is that http://192.168.255.101:8086 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">
            <mimetype>audio/L16</mimetype>
            <first-resource>yes</first-resource>
            <accept-url>yes</accept-url>
            <sample-frequency>44100</sample-frequency>
            <audio-channels>2</audio-channels>
            <hide-original-resource>yes</hide-original-resource>
            <agent command="/scripts/mediatomb-transcode.sh" arguments="-f bbcradio_playlist -i %in -o %out"/>
            <buffer size="1048576" chunk-size="4096" fill-size="1024"/>
    </profile>
    

    The mediatomb-transcode.sh 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…

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    #!/bin/bash
    transcode_to_pcm() {
      exec /usr/bin/ffmpeg -i "$1" -ac 2 -ar 44100 -y -f s16be "$2"
    }
    bbcradio_playlist() {
      INPUT=$1
      FIND_STR="File1="
      OUT_FILE=/tmp/irpls.tmp
      wget -q -O $OUT_FILE $INPUT
      LINE=`grep -e $FIND_STR $OUT_FILE`
      RADIO_URL=${LINE:${#FIND_STR}}
      rm $OUT_FILE
      transcode_to_pcm $RADIO_URL $2
    }
    while [ "$#" -gt "0" ]
    do
      case "$1" in
          -f|--func)
            FUNCTION=$2
            shift; shift;
            ;;
          -i|--input)
            INPUT=$2
            shift; shift;
            ;;
          -o|--output)
            OUTPUT=$2
            shift; shift;
            ;;
          -h|--help|*)
            echo "${USAGE}"
            exit 1
            ;;
      esac
    done
    ${FUNCTION} $INPUT $OUTPUT
    

    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