How to build an Ambilight for every HDMI input source

In this post I’m going to show how you can configure your Hyperion Ambilight for every HDMI source. If you don’t have an Ambilight setup yet, I kindly refer you to my previous guide, which will give you an initial ambilight effect for the media center running on the Rpi.

This guide will then go one step further and enable the ambilight effect for all kind of HDMI input sources like PS3, XBOX, Chromecast etc.

We need to get the color information from an HDMI input signal. For this purpose, it’s necessary to transform the digital HDMI signal to an analog composite one with a converter. After this, we can grab the composite signal with an USB video grabber connected to the Raspberry Pi. Now we’re able to feed Hyperion with the color information by the video grabber.

Parts list

AVR Receiver It’s essential. Most TVs don’t offer an HDMI output
HDMI to Analog converter Speaka Professional HDMI / Composite Converter. There are several others on the market
2 port HDMI splitter My AVR features two HDMI outputs. Otherwise make sure you’ll get one!
USB Video Grabber (Easycap) Make sure you got a grabber with the STK1160 chipset, because it’s fully supported on Linux! Check here for detailed instructions, this can be tricky…
Composite cabel Just a standard video cinch cabel
Active USB Hub The Raspberry won’t be able to power most of the devices directly from it’s USB port.

Let’s wire it up. Connect the HDMI output from your AVR or from your HDMI splitter to the HDMI / Composite converter input. Use the composite cabel for connecting the USB video grabber with the Composite converter analog output. Plug the USB video grabber into the active USB hub, connect the hub to the Raspberry Pi.

If you already have a running media center then you might already have an analog video output on this machine. In this case, connect the analog output to the grabber, directly. Another possibility would be to go for an DisplayPort to composite converter that connects to the USB grabber. For both solutions, make sure that your existing media center is capable of playing your media to both outputs, simultaneously otherwise you’ll need to go for a 2 port HDMI splitter (without AVR) and HDMI to composite converter.

Here’s my setup connected, ready for video capturing from any HDMI input.

HDMI capturing setup

 

1. USB Video Grabber setup

Connect the USB Video Grabber to the Raspberry and type

Unfortunately, my device with “ID 1b71:3002″ features a Fushicai UTV007 chip, which is only initial supported with kernel 3.11. This forced me to compile the kernel module myself. If you got the same problem, here’s my precompiled module “usbtv.ko” for Raspbmc with kernel 3.10.36. Make sure you first load the modules “videobuf2-vmalloc” and “videobuf2-core”, than load the module with insmod usbtv.ko.

The current beta release of OpenElec (4.1.6) has the driver for Fushicai UTV007 already included, therefore it will work out of the box. I’m not sure about the current Raspbmc release, though. SSH to openelec and type:

Then copy your hyperion.config.json to the shared “Configfiles” folder and reboot. Hyperion should autostart and load the config. For further instructions, make sure to checkout the documentation.

2. Hyperion configuration

Hyperion already features capturing color information from a USB video grabber. Add following configuration to your hyperion.config.json file to enable it.

To adjust the cropping for your setup, you have to change the values “cropLeft, cropRight, cropTop, cropBottom” and make sure “device” matches with your ls /dev/video* output!

Check the created screenshot.png, adjust the crop-* values till the grabbed input has no black borders left. Then put the calibrated values into your /etc/hyperion.config.json file.

Screenshot from my USB grabber input, I was able to get rid of the upper and lower borders by adjusting the cropTop and cropBottom values. The green lines are most likely from the incomplete driver for my grabber.

screenshot.png

 

Let’s test some videos! If you don’t like the results, try to fine tune your setup with different SignalThresholds or try to adjust the hsv settings.

When you switch the HDMI source on your AVR to non HDMI sources, like for example audio only devices, the LED’s will light up in blue. Blue is the default color if no video source was detected for many AVRs. You can disable the LED’s in this situation by setting the blue-threshold value to 1.0.

3. Conclusion

Now you should be able to use your Ambilight for any HDMI input you have connected to your AVR. If you have any question, feel free to ask in the comments section. Enjoy your unleashed Ambilight!

37 thoughts on “How to build an Ambilight for every HDMI input source

  1. Hi,

    Thanks alot for the help I really appreciate it. I was running 4.0.6 of OpenELEC so i will try the new beta. If this has teh driver do i need to still paste in that extra stuff in the config file?

    Best Regards

  2. Hi Chris,
    i have switched to openelec and now trying to install hyperion using on that. When i do the ‘lsusb’ i get ID 1b71:3002 and when I ask for ‘ls /dev/video’ i get ‘no such file or directory’. This isn’t going well is it?

    What else can i try? I don’t we could skype or facetime if that isn’t too much of an invasion? I’m really excited about getting this install going but fear it could take me a while to get the programming part right :0(

    Best Regards – Dumbass

    1. Hi, it doesn’t look too bad, just read carefully, I wrote: “ls /dev/video*” with a *, which should result in “/dev/video0″ and lsusb should result in: “Bus 001 Device 005: ID 1b71:3002 Fushicai USBTV007 Video Grabber [EasyCAP]“.
      Make sure, you use the latest Beta OpenElec. I tried with 4.1.6, which includes the driver. You can easily upgrade openelec by copying the *.tar file to the update folder and then reboot.

      After that, follow this installation guide for hyperion for OpenElec: https://github.com/tvdzwan/hyperion/wiki/Installation-on-RPi-with-OpenELEC
      For the hyperion LED configuration, check my previous guide.
      Regards Chris

  3. Hi Chris,

    Thanks for the tutorial, following yours has got me the closest so far and I have tried about 4!!

    I always get really stuck on the programming part and I am so close to finishing that I’m getting really frustrated so pease help. I have RaspBMC and I’m I have the Fushicai USB grabber and I’m lost on how to install the extra modules, how do I do it?

    I’m sure it’s really easy and feel free to start your reply with “Hey Dumbass”, looking forward to your reply.

    thanks

    1. Hi, I’m glad to help. Simply switch to openelec, it already includes the necessary kernel modules for the Fushicai grabber to work without loading modules.
      Anyway, what is the output of “lsusb” and “ls /dev/video*”?

      You can load the kernel driver with:
      modprobe spi-bcm2708
      modprobe videobuf2-vmalloc
      modprobe videobuf2-core
      insmod usbtv.ko
      You can download a precompiled usbtv.ko from the blog post, but I’m not sure if it will work with the recent RaspBMC builds.

      Regards Chris

  4. Hi,

    This is a great guide. I’ve followed the first half and through xbmc it’s all looking great. I have the parts for this on order.
    Do you still need a raspbmc build or can you just do it via raspbian as the input is now the usb grabber?
    Is there a setting to switch Hyperion between the USB grabber and XMBC (if you keep that build on)
    Thanks for any help and for a really brilliant guide!
    G

    1. Hi, thanks a lot.

      Basically, you can use any linux distribution that supports your USB grabber. Just make sure that your Rpi has still enough resources for running the grabber. You can switch between different hyperion clients (Hyperion app, grabber, xbmc grabber) by using the priority setting for each grabber in hyperion.config.json.
      Regards Chris

  5. Hi Christian. Thanks for your response. I’m sorry I haven’t been as quick to reply, but things have been a little hectic.

    After further reading, I agree that a USB bandwidth issue could be the source of the problem, although changing frameDecimation and sizeDecimation parameters did not manage to fix the problem. (I believe I read somewhere that frame decimation and size decimation only take place after the image has been captured by the pi (after moving through USB)).

    My lights also all occasionally flash Blue (matching the background of the XMBC) regardless of what is playing.

    I also noticed that changing “Standard” from “no-change” to “PAL” reduced the number of errors displayed before a frame was captured (even though my converter was set to “NTSC”), but in doing so the image turned to black and white again. Changing the value on the HDMI2AV converter and the config file to PAL increased the number of errors again, but made the image color.

    Do you think adjusting the configuration in framegrabber may help? Mine is currently set to defaults at:

    /// The configuration for the frame-grabber, contains the following items:
    /// * width : The width of the grabbed frames [pixels]
    /// * height : The height of the grabbed frames [pixels]
    /// * frequency_Hz : The frequency of the frame grab [Hz]
    “framegrabber” :
    {
    “width” : 64,
    “height” : 64,
    “frequency_Hz” : 10.0
    },

    I’ve also read that the SD card speed may affect results. I’m currently using a Class 4 8GB card. Do you think moving my image to a class 10 will help?

    Thank you again for your help.

    1. Hi Freddy, well I don’t think moving to a class 10 will help that much. I’m using an first generation Rpi,256 MB Ram and a class 6 SD card. Well the setting of the converter and the hyperion config should be equal.
      I’m not sure what causes the problem, you could try another usb hub or grabber.

      my settings:

      “standard” : “no-change”,
      “width” : -1,
      “height” : -1,

      Regards Chris

  6. Is it possible to run the screenshot in command in OpenELEC? When I try “hyperion-v412 –screenshot” it says “hyperion-v412 not found” and “./ hyperion-v412 –screenshot” results in “permission denied”

    1. Hi Chase, I have to look into it, since I didn’t adjust the settings after switching to openelec.

      Connect to openelec and switch to dir “/storage/hyperion/bin” and execute hyperion-v4l2 with your settings. “LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 /storage/.config/hyperion.config.json –screenshot”.

      Regards Chris

  7. Hello!

    I’m trying out your commands on my raspi running Hyperion but am getting the following errors:

    Frame too small: 824656 != 829440
    Frame too small: 823284 != 829440
    Frame too small: 818602 != 829440
    Frame too small: 821906 != 829440
    Frame too small: 817630 != 829440

    etc, where the first number constantly changes, but is always below 829440

    I am using a stk1160 and I am using the same hyperion configuration file as you and getting the same results when I do lsusb and ls/dev/video* (I also remembered to kill hyperion)

    do you have any idea what is going on? I’m having trouble understanding what could be causing this error message.

    Any help would be greatly appreciated. Thank you for creating this guide.

    1. Hi Freddy,
      It seems like hyperion receives too little information from the grabber. This could be an USB hub bandwidth issue. You could also try to increase the “frameDecimation” and “sizeDecimation” parameters in the hyperion.config.json file.
      Hope this helps, regards Chris

  8. Hi,
    I followed your guide – it helped a lot.
    I am tring to get the screenshot from my grabber but I keep getting an error:
    “VIDIOC_S_FMT error 16, Device or resource busy”

    What does this mean?
    Thanks!

  9. I will also go with one more question. As I would like to connect 4 HDMIs (TV, XBMC, PS4 and blu-ray) to the ambilight – what kind of splitter should I go with? Should I simply have 4 splitters?

  10. Dear Christian,
    Indeed great guide. I will probably follow it step by step. The only thing which bothers me is the efficiency/latency. Have you observed any delays between the screen and ambilight colours?
    Thanks,
    Tomasz

    1. Hi Thomasz,
      I didn’t observe any noteworthy delays with my USB grabber, yet. If you have 4 HDMI inputs, you probably want to connect them to an AVR and then the single output of the AVR to one single splitter. Perhaps there is a cheaper HDMI switch, to reach a simular solution.
      Regards, Chris

  11. Great guide. I’ve followed all of the instructions but I’m having an issue with the HDMI2AV converter. When I connect my HDMI source, it detects the 480p composite connection output and changes the output resolution to match, thus I see my PS4 on the TV and via the USB video grabber, but the resolution is no longer 1080p, it’s changed to 480. Does this happen on yours? Could it be an issue with the HDMI2AV converter?

    1. Hi Aaron,
      Yes, this is as it should be. Composite, analog video does not support 1080p (max 480i or 576i). So, Hyperion will capture color information from the USB video grabber with a lower resolution than the original HDMI input signal. But this doesn’t matter at all, because we just extract the color information from the signal and don’t show any images. Furthermore, your Rpi will thank you for the less work load ;-)
      Regards Chris

  12. How long is the delay with this solution compared to the XBMC-solution? You don’t happen to have a video showing the colors changes with this setup?

    1. Hi Marcus
      Well, In my opinion the delay is not really noticeable compared to the XBMC solution. I don’t have a video to show yet, but will made one soon. Will upgrade my Rpi xbmc build to the current openelec one, so I’ll be able to test with a more up to date kernel driver for my USB grabber.

  13. Hi,

    latest OpenElec testbuilds for Raspberry Pi have the usbtv module included for now on (as of 19-Jun-2014 #0619)!
    https://github.com/OpenELEC/OpenELEC.tv/issues/3140
    http://forum.xbmc.org/showthread.php?tid=192380

    So after that, it’s just a matter of installing Hyperion on Openlec (it also works for the testbuilds following the instructions from https://github.com/tvdzwan/hyperion/wiki/Installation-on-RPi-with-OpenELEC )

    I’m also using a Fushicai UTV007 (ID 1b71:3002) and it now works perfectly.

    It’s now really simple to install and simplify your how to.

    Anyway thank you very much, my ambilight is really awesome thanks to you :-)

    Regards.

    1. Hi, you’re welcome and I’m glad that you enjoy your ambilight experience!

      Yes, it seems they have closed my opened issue but I didn’t have the time to retest it, so thanks for your testing feedback! ;-)
      Regards, Chris

  14. Hi there Christian,
    Interesting post and I am going to set up the ambilight.
    1 question, my I use my old PC as my HTPC. It uses a VGA output to my television. Would this be compatible? And what changes would I have to make?

    1. Well, you have to feed the USB grabber connected to the Rpi with an analog signal from the HTPC. Perhaps your old PC supports simultaneous output of two analog video signals? You could test this with a second analog monitor connected to your HTPC.

  15. Hi Christian. Thank you very much for these instructional posts. I intend to try this out as soon as possible but I was wondering, would it suffice to use an xbox one with a HDMI splitter instead of an AVR. The xbox one has both an HDMI input and output. Thanks once again.

    1. Hi Abbas, well I don’t have a xbox one to test but it should work when you connect the xbox one HDMI output to the HDMI splitter. Then from the splitter directly to the the TV and to the HDMI to composite converter/ USB grabber which will finally lead to the Raspberry Pi.
      This way you should got ambient light for the xbox media as well for the devices connected to the xbox HDMI input.
      Regards

  16. Looks like it was a driver problem, I was able to get it working pretty well using an old kernel 3.6.11+ which had an easycap driver instead of a STK1160 driver. That worked fairly well, was down to about a .25 second delay. It also didn’t crash or randomly flash LEDs. I then tried the opposite and used a bleeding edge kernel build of Raspbian, 3.12.19+. It apparently updated the STK1160 driver and now I’m down to a .1 delay which pretty much looks good.
    I’m still looking to see if It can go any lower though. Compared to AmbiBox which I used before and running on the same computer it’s still noticeably slower. There’s almost 0 delay when it’s being generated on the same computer.

    I’ve ordered a couple more random easycap devices on Amazon to see if I can’t get a UTV007 in the mix and see if there’s a noticeable increase.

  17. You may actually have been lucky you got the Fushicai UTV007 instead of STK1160. I just got all my parts and been trying to get the STK1160 working decently, but there’s been many issues such as randomly Flashing LED and when it does work there’s about .75 second delay which for the lights is unusable.
    Reading some of the comments on Hyperion’s forum it seems the Fushicai is actually the way to go.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">