memetic dot org

Raspberry Pi XBMC and DTS Audio

by on Jul.07, 2012, under Linux, Overclocking, Raspberry Pi, XBMC

Raspberry Pi

I finally got a Raspberry Pi last week. To my shame I caved in and bought one from Ebay for £57 inc delivery. I think it’s probably still worth that much though. The Raspberry Pi, for anyone who’s been living under a rock, is a credit card-sized ARM-based computer which sells for $35 or about £30 including delivery.

Specifications include:

Raspberry Pi Board

Broadcom BCM2835 SoC
CPU – 700MHz ARM1176JZF ARMv6 (ARM11)
GPU – 250MHz VideoCore IV (OpenGL ES 2.0, 1080p h.264 L4.1 40Mbps, MPEG-4)
SDRAM – 256MB
USB Ethernet controller + 2 USB ports
HDMI + Composite + DSI
SD slot
8xGPIO, UART, I2C, SPI.

All this is powered from a single 700mA (3.5w at 5v) MicroUSB connection.

I’d been planning to try it out as an XBMC media centre and a Linux/Samba file server. The ARM is a little slow but being able to do H.264 and MPEG4 ASP in should hopefully ensure CPU won’t hold it back too much when playing media.

XBMC

XBMC Main Screen

Getting XBMC on the RasPi was simple, just download a Windows (or Mac or Linux) autoinstaller from raspbmc.com (currently down) which will install a bootstrap to your SD card. You then boot up your RasPi with that in the slot and it automatically downloads the latest build of RaspBMC, installs it onto your card and reboots into XBMC.

The first thing I noticed was that the background images have been removed from the default Confluence skin and replaced with a single static image for all options, I assume this is to reduce memory and CPU load on the poor ARM. The interface is usable, but obviously not as quick as my Atom/ION machine.

Initially I attached the RaspBMC to my XBMC MySQL database, but the interface became a little too slow to be usable. I’ll have to try this again later to see if I can speed it up.

XBMC Summary

When I came to try some content nothing would play smoothly at 1080p and only about half of the 720p content I tried would play smoothly. It turns out that the ARM CPU just doesn’t have enough grunt to decode the DTS audio found on almost all 1080p and most 720p content. Almost XviD content I tried played fine, one or two had some hiccuping and one or two just refused to play, I think this is probably related to the encoding features used.

The situation is a little better for content played from a USB-attached hard disk or flash drive, but it’s still not quite fast enough to play the DTS streams. It seems that the USB network adaptor is a bit of a CPU hog.

Apparently this is a common irritation for people wanting to use the RasPi as a media centre. That, and the lack of hardware MPEG2 decoding making it impossible to decode many HD broadcast streams. This isn’t an issue for me, and anyone who really needs MPEG2 decoding will probably have other options.

Overclocking and Raspbian armhf

To fix the DTS issue I decided to try to overclock the Pi. It has a little headroom for overclocking, the creators say that almost all Pis should be able to hit 800MHz and many are reported to go much faster.

See the post on Raspberry Pi Overclocking for more details.

The highest overclock I achieved which was stable in XBMC was 1050MHz on the ARM core, 450MHz on the RAM and 500MHz on the GPU core. At those speeds the Pi still couldn’t quite decode DTS audio streams.

I also installed Raspbian, which uses armhf and provides a significant performance improvement on the RasPi. See the post on Raspbian Benchmarking – armel vs armhf for more details.

Breakdown of audio decoding performance for various configurations of the Raspberry Pi

Breakdown of audio decoding performance for various configurations of the Raspberry Pi

I tested the performance of the Pi at decoding various audio formats on the armel and armhf architectures and with the stable clock. The chart above shows the %age of CPU required to decode the various audio formats in real time.

Using Raspbian overclocked to 1GHz and my XBMC binaries I was able to play back a relatively high-bitrate H.264 (~20Mbps) video file with 1.5Mbit DTS audio successfully from a USB hard disk and from a local samba file server with relatively high success rates, but still not perfectly. There still seems to be problems when the video bitrate goes above ~20Mbit. Note that the core_freq=500 overclock was important, without it the playback still stuttered.

Below are the config.txt settings for my highest stable XBMC overclock.

arm_freq=1050
core_freq=500
sdram_freq=450
over_voltage=6
over_voltage_sdram=0
disable_overscan=1

Audio Transcoding

I finally decided that I would transcode all of my DTS audio-streams to an alternative format so that they’ll play properly on the RPi over the network. I’m no audiophile and I don’t have a fancy home theater setup, so I decided to transcode all of the audiostreams to 192Kbps stereo AAC, which should surpass 256Kbit MP3 in quality. If you wanted to retain your 5.1 surround you could use 5.1 448Kbps AAC, which the RasPi seems to be able decode without issues.

I modified a shell script used to transcode DTS to AC3. It scans the MKV container and upon detecting a DTS or AC3 file converts them to AAC and re-merges the MKV. I copy the original MKV into a large ramdisk first, as the entire file has to be scanned 3 times during the process.

Transcoding from DTS to AAC can save about 1GB on an average 2 hour file.

Original Filesize: 4,578,516 KB
Extracted DTS Filesize: 1,024,072 KB
Converted AAC Filesize: 114,224 KB
Final Filesize: 3,666,592 KB

Transcoding from AC3 to AAC will save 2-400MB.

Original Filesize: 4,575,228 KB
Extracted AC3 Filesize: 513,364 KB
Converted AAC Filesize: 135,036 KB
Final Filesize: 4,194,832 KB

The transcoding is relatively quick, a 2-3 minutes for AC3 and 5 minutes for DTS.

Of course, none of this would be an issue if you have a DTS/AC3-capable audio decoder, as then the audio would be passed through to the decoder with no processing done on the RasPi.

Conclusion

After an hour’s effort of modifying the script and testing it, I’ve now got a perfectly usable and very low media centre device and as a bonus a shed load of newly-freed up storage space!

I’m quite impressed with the Raspberry Pi so far, even given its shortcomings. I intend to carry one around with me when I’m using hotels so that I can play movies on the hotel TV. I also plan to take a couple to Mexico with me the next time I go over there to act as media centre and file servers in the house.


27 Comments for this entry

  • sly

    Hi Adama,
    Would you mind sharing your script with me?
    I’ve got the same problem with a lot of DTS audio Mkv.

    Best Regards,
    sly

  • ph0ng

    I agree with sly, once you’ve posted a teaser of the transcode script you can’t keep us on a leash like this :)

  • Salamander

    Have you tested OpenELEC? It also supports hard floating point operations. Might be faster than raspbmc/raspbian.

    http://wiki.openelec.tv/index.php?title=Installing_OpenELEC_on_Raspberry_Pi

    • adama

      I tried darkelec. It seemed to behave oddly, probably because of an old kernel. My installation of XBMC on Raspbian is pretty cut down, I kill off all of the background processes, so there’s nothing else to optimise.

      • Salamander

        OpenELEC is a totally different implementation of XBMC. Different kernel and OS than Raspbian. There are some reports out there stating that OE performs better, even with DTS fully operational (i.e. http://openelec.tv/forum/124-raspberry-pi/38818-raspberry-pi-feedback#40074). Just think it would be great to have a comparative benchmark ‘OE vs Raspbian+XBMC’.

        • adama

          I find that DTS working or not is a very hit and miss thing. I had it working yesterday, then after pausing the playback it refused to work again! Even a reboot didn’t fix it. I’ve no idea what it is.

          There can’t be a great deal of performance difference really. I prefer to not use openelec so i can ssh in and do other things.

  • Marc

    Is this possible to have a copy your script ?

    • adama

      at some point i will get around to posting the script. you can find the original by googling, though “mkvdts2ac3″. i merely modified it to convert to AAC (as AC3 is a bit crap)

  • Adam

    Hi,

    Could you please explain me why you chose to build your own XBMC instead of rebuilding wheezy’s debian package for armhf ?
    I just set up a cross-arch cowbuilder for raspian and I’m currently building “official” XBMC package inside.
    For now, it goes well.

    Regards, Adam.

  • Mirco

    Worked great! But I am missing Audio through Hdmi, Hdmi CEC, Airplay and if videos are running I see a piece of the RPi logo at the top and the cursor at the bottom. :) Perhaps it is because you used an Android version? :/

    • adama

      Airplay and HDMI CEC are not enabled on this build. HDMI Audio works fine if you follow the guide and don’t fiddle with things unnecessarily (I’ve never had it not work). What kind of stupid suggestion is that? No it’s not the Android version, perhaps it’s because you’re a fool?

  • Leif Hedstrom

    Are you planning on updating this package as XBMC makes new beta releases? The iPhone app seems to have stopped working with this “older” version for example?

    Thanks for putting it together though, much appreciated.

  • Friends with Kids download

    Thank you, I’ve recently been searching for information approximately this topic for a while and yours is the greatest I have discovered till now. But, what in regards to the conclusion? Are you certain in regards to the supply?|What i don’t realize is in reality how you’re now not really a lot more smartly-preferred than you may be now. You are very intelligent.

  • Markos

    I wish to express appreciation to the writer just for bailing me out of this scenario. Right after exploring throughout the online world and seeing ideas which are not helpful, I thought my life was gone. Living devoid of the answers to the issues you’ve solved by means of the post is a crucial case, as well as the ones which may have in a wrong way affected my entire career if I had not come across the website. Your actual talents and kindness in touching the whole thing was invaluable. I don’t know what I would’ve done if I hadn’t encountered such a thing like this. It’s possible to at this moment look ahead to my future. Thanks for your time very much for your professional and amazing help. I will not hesitate to endorse your web sites to anyone who needs to have guidance on this subject matter.

  • joe schmoe

    Great article. I’ve done the same…jumping through hoops..converting DTS-MA to LPCM to get it playing.

    However latest Raspbmc eliminates that step because it will decode DTS stream even at 850Mhz CPU clock.

    What I have found problems with is when the DTS-MA track is 96KHz instead of the more common 48KHz. Anyone else experience the same? It still stutters.

  • joe schmoe

    BTW…under “Specifications” in your article, doesn’t your board have 512MB of ram not 256MB?

  • Going To Get Minecraft For Free? Read My Guide

    This blog was… how do you say it? Relevant!!
    Finally I have found something that helped me. Thanks a lot!

    Stop by my blog … Going To Get Minecraft For Free? Read My Guide

  • FM BUG PCB

    Great issues here. I will be incredibly glad to visit your document. Many thanks and i’m having a look ahead of time to feel an individual. Can you i implore you to lower me a send?

  • Rhea

    Write more, thats all I have to say. Literally, it
    seems as though you relied on the video to make your
    point. You clearly know what youre talking about, why waste your intelligence on
    just posting videos to your blog when you could be giving us something enlightening
    to read?

  • website-reviews.info

    Attractive component to content. I simply stumbled upon your
    website and in accession capital to claim that I get in fact
    loved account your weblog posts. Anyway I’ll be subscribing to your augment or even I fulfillment you get admission to consistently rapidly.

  • Leslie

    Simply wish to say your article is as astounding. The clearness in your post is simply
    nice and i could assume you’re an expert on this subject. Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please carry on the enjoyable work.

  • iphone,i-phone,i phone,ipad,iphone apps,apps

    I just could not depart your site prior to suggesting that I extremely enjoyed the usual information an individual supply for your guests? Is gonna be back continuously to check up on new posts

1 Trackback or Pingback for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...

Archives

All entries, chronologically...