Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] mediatomb + transcoding + online radio stream
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
buccia
n00b
n00b


Joined: 26 Aug 2006
Posts: 40

PostPosted: Sat Mar 22, 2014 11:00 pm    Post subject: [SOLVED] mediatomb + transcoding + online radio stream Reply with quote

I can get mediatomb to serve online radio stations that stream in a directly supported format, like mp3. But I can't get the transcoding mechanism to work for other radio stations.

Here's my scenario. BBC Radio 1 provide the following stream in the form of a playlist:
Code:
http://www.bbc.co.uk/radio/listen/live/r1_aaclca.pls

I set up the following item from mediatomb web interface:
Code:
Title: BBC Radio 1
URL: http://www.bbc.co.uk/radio/listen/live/r1_aaclca.pls
Protocol: http-get
Class: object.item.audioItem.musicTrack
Mimetype: audio/x-bbcradio

In the config.xml file I first enabled transcoding:
Code:
<transcoding enabled="yes">

I then created an entry for the audio/x-bbcradio mimetype in the <mimetype-profile-mappings> section:
Code:
<transcode mimetype="audio/x-bbcradio" using="bbc2pcm"/>

Finally I created the bbc2pcm profile in the <profiles> section:
Code:
<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="/usr/local/share/mediatomb/scripts/mediatomb-transcode.sh" arguments="-f transcode_playlist_to_pcm -i %in -o %out -t pls"/>
  <buffer size="1048576" chunk-size="4096" fill-size="1024"/>
</profile>

After I restart the mediatomb server I can see the BBC Radio 1 entry on my upnp device. However when I try to play it my transcoding script (mediatomb-transcode.sh, as defined above) never gets executed (to be sure I put a command to print something to a log file, as the first command in the script). The server's log file shows the following:
Code:
ERROR: no valid handler type in /content/online/object_id/17152/res_id/none/pr_name/bbc2pcm/tr/1

If I understood the logic correctly, the audio/x-bbcradio mimetype should direct the server to the bbc2pcm profile which, in turn, should cause the script in the <agent> element to be executed. But it's not happening. The script has the correct permissions and I can run it manually. Any idea what I'm missing?


Last edited by buccia on Mon Mar 24, 2014 1:17 pm; edited 1 time in total
Back to top
View user's profile Send private message
BT
Apprentice
Apprentice


Joined: 13 Jun 2004
Posts: 249

PostPosted: Sun Mar 23, 2014 10:44 am    Post subject: Reply with quote

Could you post the contents of mediatomb-transcode.sh?
Back to top
View user's profile Send private message
buccia
n00b
n00b


Joined: 26 Aug 2006
Posts: 40

PostPosted: Sun Mar 23, 2014 12:46 pm    Post subject: Reply with quote

Thanks for the reply. It's here: https://dl.dropbox.com/u/11307644/mediatomb/mediatomb-transcode.sh

I followed the guidance provided here: http://www.simpsoncomputers.co.uk/blog/?p=611. I just added the following line just after the last subroutine definition (i.e. to be the first executed command):
Code:
printf "Im here\n" > /tmp/aalog

However, the script never gets executed. I don't think I've reached a point where I need to worry about whether the script does the right thing or not.
Back to top
View user's profile Send private message
BT
Apprentice
Apprentice


Joined: 13 Jun 2004
Posts: 249

PostPosted: Sun Mar 23, 2014 2:03 pm    Post subject: Reply with quote

I got it working with the configuration you gave. Can you paste your entire config.xml.
Back to top
View user's profile Send private message
buccia
n00b
n00b


Joined: 26 Aug 2006
Posts: 40

PostPosted: Sun Mar 23, 2014 5:05 pm    Post subject: Reply with quote

config.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd">
  <server>
    <ui enabled="yes" show-tooltips="yes">
      <accounts enabled="no" session-timeout="30">
        <account user="mediatomb" password="******"/>
      </accounts>
    </ui>
    <name>MediaTomb</name>
    <udn>uuid:7256ea4b-6157-426f-935a-a4620e8791e9</udn>
    <home>/var/lib/mediatomb</home>
    <webroot>/usr/share/mediatomb/web</webroot>
    <storage>
      <sqlite3 enabled="no">
        <database-file>mediatomb.db</database-file>
      </sqlite3>
      <mysql enabled="yes">
        <host>localhost</host>
        <database>mediatomb</database>
        <username>mediatomb</username>
        <password>*********</password>
      </mysql>
    </storage>
    <protocolInfo extend="yes"/>
    <pc-directory upnp-hide="yes"/>
    <extended-runtime-options>
      <ffmpegthumbnailer enabled="no">
        <thumbnail-size>160</thumbnail-size>
        <seek-percentage>10</seek-percentage>
        <filmstrip-overlay>no</filmstrip-overlay>
        <workaround-bugs>no</workaround-bugs>
        <image-quality>8</image-quality>
      </ffmpegthumbnailer>
      <mark-played-items enabled="no" suppress-cds-updates="yes">
        <string mode="prepend">*</string>
        <mark>
          <content>video</content>
        </mark>
      </mark-played-items>
      <lastfm enabled="no">
        <username>username</username>
        <password>password</password>
      </lastfm>
    </extended-runtime-options>
  </server>
  <import hidden-files="no">
    <scripting script-charset="UTF-8">
      <common-script>/usr/share/mediatomb/js/common.js</common-script>
      <playlist-script>/usr/share/mediatomb/js/playlists.js</playlist-script>
      <virtual-layout type="js">
        <!-- <import-script>/usr/share/mediatomb/js/import.js</import-script> -->
        <import-script>/etc/mediatomb/import.js</import-script>
      </virtual-layout>
    </scripting>
    <mappings>
      <extension-mimetype ignore-unknown="no">
        <map from="mp3" to="audio/mpeg"/>
        <map from="ogx" to="application/ogg"/>
        <map from="ogv" to="video/ogg"/>
        <map from="oga" to="audio/ogg"/>
        <map from="ogg" to="audio/ogg"/>
        <map from="ogm" to="video/ogg"/>
        <map from="asf" to="video/x-ms-asf"/>
        <map from="asx" to="video/x-ms-asf"/>
        <map from="wma" to="audio/x-ms-wma"/>
        <map from="wax" to="audio/x-ms-wax"/>
        <map from="wmv" to="video/x-ms-wmv"/>
        <map from="wvx" to="video/x-ms-wvx"/>
        <map from="wm" to="video/x-ms-wm"/>
        <map from="wmx" to="video/x-ms-wmx"/>
        <map from="m3u" to="audio/x-mpegurl"/>
        <map from="pls" to="audio/x-scpls"/>
        <map from="flv" to="video/x-flv"/>
        <map from="mkv" to="video/x-matroska"/>
        <map from="mka" to="audio/x-matroska"/>
        <map from="avi" to="video/divx"/>
        <map from="m2ts" to="video/avc"/>
        <map from="cr2" to="image/raw"/>
        <map from="nef" to="image/raw"/>
      </extension-mimetype>
      <mimetype-upnpclass>
        <map from="audio/*" to="object.item.audioItem.musicTrack"/>
        <map from="video/*" to="object.item.videoItem"/>
        <map from="image/*" to="object.item.imageItem"/>
      </mimetype-upnpclass>
      <mimetype-contenttype>
        <treat mimetype="audio/mpeg" as="mp3"/>
        <treat mimetype="application/ogg" as="ogg"/>
        <treat mimetype="video/ogg" as="ogg"/>
        <treat mimetype="audio/ogg" as="ogg"/>
        <treat mimetype="audio/x-flac" as="flac"/>
        <treat mimetype="image/jpeg" as="jpg"/>
        <treat mimetype="audio/x-mpegurl" as="playlist"/>
        <treat mimetype="audio/x-scpls" as="playlist"/>
        <treat mimetype="audio/x-wav" as="pcm"/>
        <treat mimetype="audio/L16" as="pcm"/>
        <treat mimetype="video/x-msvideo" as="avi"/>
        <treat mimetype="video/mp4" as="mp4"/>
        <treat mimetype="audio/mp4" as="mp4"/>
        <treat mimetype="video/divx" as="avi"/>
      </mimetype-contenttype>
    </mappings>
    <online-content>
      <YouTube enabled="no" refresh="28800" update-at-start="yes" purge-after="604800" racy-content="exclude" format="mp4" hd="no">
        <favorites user="NationalGeographic"/>
        <playlists user="PlayStation"/>
        <uploads user="Google"/>
        <standardfeed feed="most_viewed" time-range="today"/>
        <standardfeed feed="recently_featured" time-range="today"/>
      </YouTube>
    </online-content>
  </import>
  <transcoding enabled="yes">
    <mimetype-profile-mappings>
      <transcode mimetype="audio/ogg" using="audio2pcm"/>
      <transcode mimetype="audio/x-flac" using="audio2pcm"/>
      <transcode mimetype="audio/x-bbcradio" using="bbc2pcm"/>
      <transcode mimetype="video/ogg" using="video2mpeg"/>
      <transcode mimetype="video/x-flv" using="video2mpeg"/>
    </mimetype-profile-mappings>
    <profiles>
      <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>
      <profile name="video2mpeg" enabled="yes" type="external">
        <mimetype>video/mpeg</mimetype>
        <accept-url>no</accept-url>
        <first-resource>yes</first-resource>
        <hide-original-resource>yes</hide-original-resource>
        <accept-ogg-theora>yes</accept-ogg-theora>
        <sample-frequency>48000</sample-frequency>
        <audio-channels>2</audio-channels>
        <agent command="ffmpeg" arguments="-i %in -vcodec mpeg2video -b 4096k -r 25 -acodec mp2 -ab 192k -ar 48000 -ac 2 -async 1 -f dvd -threads 2 -y %out"/>
        <buffer size="10485760" chunk-size="262144" fill-size="524288"/>
      </profile>
      <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="/usr/local/share/mediatomb/scripts/mediatomb-transcode.sh" arguments="-f transcode_playlist_to_pcm -i %in -o %out -t pls"/>
        <buffer size="1048576" chunk-size="4096" fill-size="1024"/>
      </profile>
    </profiles>
  </transcoding>
</config>

Here's the server's conf.d file:
Code:
# /etc/conf.d/mediatomb: config file for /etc/init.d/mediatomb

# See the mediatomb(1) manpage for more info.

# MediaTomb Web UI port.
# NOTE: The minimum value allowed is 49152
MEDIATOMB_PORT=49152

# Run MediaTomb as this user.
# NOTE: For security reasons do not run MediaTomb as root.
MEDIATOMB_USER="mediatomb"

# Run MediaTomb as this group.
# NOTE: For security reasons do not run MediaTomb as root.
MEDIATOMB_GROUP="mediatomb"

# Path to MediaTomb config file.
MEDIATOMB_CONFIG="/etc/mediatomb/config.xml"

# Path to MediaTomb log file.
MEDIATOMB_LOGFILE="/var/log/mediatomb.log"

# Path to MediaTomb pid file.
MEDIATOMB_PIDFILE="/var/run/mediatomb.pid"

# Other options you want to pass to MediaTomb.
# Add "--interface ${MEDIATOMB_INTERFACE}" to bind to a named interface.
MEDIATOMB_OPTIONS="-e enp0s7"

Here's the output I get in the log file when I try to play BBC Radio 1 from BubbleUPnP controller, when I start the server with the --debug option:
Code:
2014-03-23 16:51:39   DEBUG: [../src/web_callbacks.cc:72] create_request_handler(): Filename: /content/online/object_id/17152/res_id/none/pr_name/bbc2pcm/tr/1, Path: (null)
2014-03-23 16:51:39   ERROR: no valid handler type in /content/online/object_id/17152/res_id/none/pr_name/bbc2pcm/tr/1
2014-03-23 16:51:54   DEBUG: [../src/storage/mysql/mysql_storage.cc:113] threadCleanup(): thread cleanup; thread_id=-792021248
2014-03-23 16:51:55   DEBUG: [../src/storage/mysql/mysql_storage.cc:113] threadCleanup(): thread cleanup; thread_id=-746592512
Back to top
View user's profile Send private message
BT
Apprentice
Apprentice


Joined: 13 Jun 2004
Posts: 249

PostPosted: Mon Mar 24, 2014 1:10 am    Post subject: Reply with quote

Your config.xml is correct and I have it working with my PS3 and BubbleUPnP on Android.

I was able to reproduce the error you get by disabling the MediaTomb curl USE flag, so I'm guessing you don't have it enabled. The curl USE flag is needed when you want to transcode external sources.
Back to top
View user's profile Send private message
buccia
n00b
n00b


Joined: 26 Aug 2006
Posts: 40

PostPosted: Mon Mar 24, 2014 1:16 pm    Post subject: Reply with quote

Thank you so much! Enabling the curl USE flag did the trick.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum