Mediatomb convert to wav on the fly and stream to Chromecast Audio

rodp

Member
Hi All,

I've got a number of Chromecast Audio devices setup at home and would like to play the radio recordings (MP3 layer 2 I'm afraid!) from my HDR Fox T2. CC Audio units are limited to MP3 layer 3 (not loayer 2), Frac, WAV and a few other formats I think. I understand that to convert to MP3 layer3 is not possible on the hummy in an efficient way but can the hummy transcode to Wav on the fly and then stream that to the Chromecast?

I read somewhere that Mediatomb might be able to be setup to do this transcoding / conversion but how this is done I'm not sure and whether the version on the hummy allows this.

I'm currently using Android BubbleUPNP to transcode to WAV on the fly and stream to the CC Audio which eats into my phones battery major style and so it would be good to know if the hummy can do this all by itself. To id which files would need transcoding I could simply rename the extension to something specific (eg. mp3.towav)

Any advice would be much appreciated

Thanks

Rodp
 
There's no chance of doing anything on-the-fly, the HDR-FOX has a very feeble processor and resources, and all the clever stuff it does is in hardware we can't get to.

As long as you are not in a hurry, your HDR-FOX recordings from Freeview radio services can be automatically converted to proper MP3 in slow time - just leave the unit turned on and leave it to get on with it. All you need to do is WebIF >> Settings >> General Settings >> Audio extraction type = MP3, then set "Enable Auto-decrypt" and "Enable Auto-audio" on any folder that will be recorded into (what I do is have a pre-set folder "[MP3]" with those properties, and dump anything I want converted into it).

Bear in mind that once an MP3 has been created, it will not be visible or manipulable from the Humax menu system (unless it is stored under "My Music" and you select Media = Music), and probably won't be available by DLNA. The ChromeCast will have to reach in by network access (SMB/NFS), and you will need to run the samba or nfs-utils package so that the contents are available to the network.
 
Hi Black Hole,

Thanks for the reply - that's a shame. Out of interest though, has anyone tried converting mp3 (layer 2 or 3) to WAV on the box and how long it takes / what the rate is? I'll have a go myself if someone could help me with the command line - do you do this via telnet? Is there an easy way to know how long it takes and through put. I think I'd need about 1-2 mb/s to keep up with the stream rate if there was anything but a slim chance.

FYI: I use mediatomb and have amended it's config file to see wav extensions so that I can use a UPNP DLNA app (use BubbleUPNP and UPnPlay mostly). Works pretty well and there's then no need for samba or nfs-utils. :D

Thanks

Rodp
 
FYI: I use mediatomb and have amended it's config file to see wav extensions so that I can use a UPNP DLNA app (use BubbleUPNP and UPnPlay mostly). Works pretty well and there's then no need for samba or nfs-utils. :D
Yeah, fair point, you mentioned Mediatomb before and it slipped my mind when I was replying - but actually you might be better off with samba instead (if the ChromeCast can use SMB).

Regarding the command line, you can reach in by Telnet or install webshell and use WebIF >> Diagnostics >> Command Line (which brings up a console; thoroughly recommended, needs a reboot after installing).

Once you have the command prompt, use ls and cd to navigate to your target recording, then it will be an ffmpeg command to perform the conversion - you can google the ffmpeg command line parameters just as well as I can. Bear in mind that you cannot close the command window (even if it's a Telnet session) until the conversion is completed, whereas the WebIF Auto-audio function runs in the background.
 
I just tried it and a minute of audio takes about 13 seconds, so well above the rate that's needed.
Code:
humax# ffmpeg -i whatever.mp3 whatever.wav
 
Thanks prp..... ok, so transcoding from mp3 to wav on the fly might be possible? :eek: I'll have to find the page I came across about transcoding in mediatomb....
 
So the next question is whether Mediatomb can be configured to perform the conversion...

...but I don't understand why not simply run the proper MP3 conversion in the first place. Is there some kind of deadline?
 
Just out of interest, I tried it on my PC and it converted at 6 minutes per second, so roughly 80 times the speed!
 
I record 3 hour shows(!!) so that will likely take a few days / week in which case my hummy will boot up and shut down many times so not really practical to use the mp3 layer 3 option as there is no resume conversion feature (or at least I don't believe there is).
 
3 hour programme should only take about 40 minutes to convert.
does this look promising?
Possibly. I haven't found any sort of usable reference for all that damned XML. Bl@@dy documentation is useless, as is usual with these things. It's no wonder these projects die.
Now I have to recall where the mediatomb config file is and location of ffmpeg
/mod/mediatomb/config/config.xml (I would guess)
/mod/bin/ffmpeg (although you can probably just use "ffmpeg")
 
Found a bit more detail here: http://www.linuceum.com/Server/srvDLNATrans.php

So I've used this link and the above link to create the following config.xml profile - currently untested - waiting for humax to reboot but it's busy at the moment. Let me know if you spot anything which won't make it work. In short I've created a new audio extension called .mp3L2 (assuming it will accept more than 3 characters!) and given it a mimetype called audio/x-mp3L2toWav which then refers to a transcoding profile called mp3L2toWav. This profile then calls up ffmpeg where the output format is s16be (16 bit big-endian raw pcm, ie wav I think!). It would be nice to simply tell ffmpeg to output a .wav file but I'm not sure how you do this in this context as you need to use the %out stream.

I'm also not sure about the line: <treat mimetype="audio/x-mp3L2toWav" as="pcm"/>

Below is 1st draft of the revised code

Thanks

Rodp

Code:
<?xml version="1.0" encoding="UTF-8"?>
<config version="1" xmlns="http://mediatomb.cc/config/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/1 http://mediatomb.cc/config/1.xsd">
  <server>
    <ui enabled="yes">
      <accounts enabled="no" session-timeout="30">
        <account user="mediatomb" password="mediatomb"/>
      </accounts>
    </ui>
    <name>MediaTomb HDR-Fox-T2</name>
    <udn>uuid:9026056d-0032-4501-94c6-a4dee9fcd325</udn>
    <home>/mod/mediatomb/config</home>
    <webroot>/mod/mediatomb/web</webroot>
    <storage>
      <sqlite3 enabled="yes">
        <database-file>mediatomb.db</database-file>
      </sqlite3>
    </storage>
    <protocolInfo extend="no"/><!-- For PS3 support change to "yes" -->
    <!--
       Uncomment the lines below to get rid of jerky avi playback on the
       DSM320 or to enable subtitles support on the DSM units
    -->
    <!--
    <custom-http-headers>
      <add header="X-User-Agent: redsonic"/>
    </custom-http-headers>

    <manufacturerURL>redsonic.com</manufacturerURL>
    <modelNumber>105</modelNumber>
    -->
    <!-- Uncomment the line below if you have a Telegent TG100 -->
    <!--
       <upnp-string-limit>101</upnp-string-limit>
    -->
  </server>
  <import hidden-files="no">
    <magic-file>/mod/mediatomb/file/magic</magic-file>
    <scripting script-charset="UTF-8">
      <common-script>/mod/mediatomb/js/common.js</common-script>
      <playlist-script>/mod/mediatomb/js/playlists.js</playlist-script>
      <virtual-layout type="builtin">
        <import-script>/mod/mediatomb/js/import.js</import-script>
      </virtual-layout>
    </scripting>
    <mappings>
      <extension-mimetype ignore-unknown="yes">
        <map from="ts" to="video/mpeg"/>
        <map from="mp3" to="audio/mpeg"/>
        <map from="mp4" to="video/mp4"/>
        <map from="ogg" to="application/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="wav" to="audio/x-wav"/>
        <map from="mp3L2" to="audio/x-mp3L2toWav"/>
        <!-- Uncomment the line below for PS3 divx support -->
        <!-- <map from="avi" to="video/divx"/> -->
        <!-- Uncomment the line below for D-Link DSM / ZyXEL DMA-1000 -->
        <map from="avi" to="video/avi"/>
      </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="video/mp4" as="mp4"/>
        <treat mimetype="application/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/x-mp3L2toWav" as="pcm"/>
        <treat mimetype="audio/L16" as="pcm"/>
        <treat mimetype="video/x-msvideo" as="avi"/>
      </mimetype-contenttype>
    </mappings>
  </import>
  <transcoding enabled="yes">
    <mimetype-profile-mappings>
      <transcode mimetype="video/x-flv" using="vlcmpeg"/>
      <transcode mimetype="application/ogg" using="vlcmpeg"/>
      <transcode mimetype="application/ogg" using="oggflac2raw"/>
      <transcode mimetype="audio/x-flac" using="oggflac2raw"/>
      <transcode mimetype="audio/x-mp3L2toWav" using="mp3L2toWav"/>
    </mimetype-profile-mappings>
    <profiles>
      <profile name="oggflac2raw" enabled="no" type="external">
        <mimetype>audio/L16</mimetype>
        <accept-url>no</accept-url>
        <first-resource>yes</first-resource>
        <accept-ogg-theora>no</accept-ogg-theora>
        <agent command="ogg123" arguments="-d raw -f %out %in"/>
        <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
      </profile>
      <profile name="vlcmpeg" enabled="no" type="external">
        <mimetype>video/mpeg</mimetype>
        <accept-url>yes</accept-url>
        <first-resource>yes</first-resource>
        <accept-ogg-theora>yes</accept-ogg-theora>
        <agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>
        <buffer size="14400000" chunk-size="512000" fill-size="120000"/>
      </profile>
      <profile name="mp3L2toWav" enabled="yes" type="external">
        <mimetype>audio/x-wav</mimetype>
        <accept-url>no</accept-url>
        <first-resource>yes</first-resource>
        <accept-ogg-theora>yes</accept-ogg-theora>
        <sample-frequency>44100</sample-frequency>
        <audio-channels>2</audio-channels>
        <hide-original-resource>yes</hide-original-resource>
        <agent command="/mod/bin/ffmpeg" arguments="-i %in -ac 2 -ar 44100 -y -f s16be %out"/>
        <buffer size="1048576" chunk-size="4096" fill-size="1024"/>
      </profile>
    </profiles>
  </transcoding>
</config>
 
Last edited:
nope - 1st attempt doesn't work - even via Android app. I can see the MP3L2 format and when I select it to play it starts downloading something but no sound starts and then after about 1Mb it stops downloading.

Any help much appreciated

Thanks

Rodp
 
turning off the transcoding part lets BubbleUPNP pick up the mp3L2 format, transcode it to wav by itself and play on chromecast audio. And so it looks like it's the transcoding part of the config file which isn't quite right.
 
oooooo!!!! changed s16be to wav and it's working without bubbleupnp on my phone transcoding :D

So the only drawback is you can't fast forward / rewind (cue / review) the track but pausing works fine. CPU usage about 30% and network peaking at about 1.9Mb/s so that's ok. Will have to see what happens whilst the hummy is recording 1 or 2 programs.
 
Doesn't work on using UPnPlay or UPnP Monkey - They must handle the Get http url address slightly differently. UPnP Monkey for example will work fine with normal MP3 (layer 3) using the official 'HDR-FOX T2 Media Server' but not 'MediaTomb HDR-Fox-T2'.

If you think that there might be a way to control fast forward / rewind controls please do let me know.

Right - job done - off to bed. :)

Rodp
 
If you think that there might be a way to control fast forward / rewind controls please do let me know.
That's one of the big drawbacks with DLNA that I found and what caused me to abandon it as not worth bothering with.
 
what do you use instead prp? perhaps I'm trying to reinvent the wheel here!.... I guess you're propably going to say Samba but my problem is I need to transcode.
 
Yes, network storage. I still don't understand your need to transcode on the fly - other than impatience. I don't turn my HDRs off, and if you must have a faster process than MP2 > MP3, use MP2 > WAV. In fact, you can go straight from TS > WAV.
 
How do you ensure the HDR stays on? I find that whenever it records and then stops recording it turns itself off. How can I ensure that the unit stays on whilst it's transcoding to MP3 L3?

Plus there are times we have to turn the box off (to standby) or else it loses HDMI sync with the TV and the TV shows either a green screen or nothing at all. :S

Thanks

Rodp
 
Back
Top