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, make sure that you got one with 1080p support. Check this guide for more details about the available chipsets
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…I’d recommend a grabber with the UTV007 (Fushicai) chipset. It’s supported with OpenElec >=4.2.1 and features the best results for this purpose.
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.


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.

OpenElec (>=4.2.1) has the driver for Fushicai UTV007 already included, therefore it will work out of the box. Remember, to enable ssh you have to boot OpenElec with TV connected. After that, you won’t need the installed XBMC/KODI anymore. It seems like the current Raspbmc release has the driver not included. SSH to openelec and install hyperion:

Then copy your hyperion.config.json to the shared SMB “Configfiles” folder from your host system. The shared “Configfiles” folder is actually mapped to /storage/.config on the Rpi filesystem. After a Rpi reboot, Hyperion should autostart and load the config from /storage/.config/hyperion.config.json automatically, though.

Remember that you have to set the library path for OpenElec setups before you can execute any hyperion command:

Stop / Restart hyperion manually:

Take a screenshot from the grabber with following command. Remember to kill hyperiond before you can execute this command properly!

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. I was able to get rid of the green lines after increasing “frameDecimation” to 8 but then a lot of frames were skipped and the LED’s were out of sync to the moving picture. So I set it back to 2.

If you only want to grab the signal from the v4l2 video grabber, make sure that you remove the “framegrabber” and xbmcVideoChecker sections.

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. Make sure to read this comprehensive guide about color transformation.

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!

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

  1. Good morning.I managed to install and run my LED strip with Open Elec, but when trying to install video grabber (fushicai) LEDs do not follow the TV (set top box). I connected as follows: (RPI – TV); (Set top box – TV and grabber) and (grabber – RPI).
    My Json setting was so.

    “endOfJson” : “endOfJson”,
    /// Configuration for the embedded V4L2 grabber
    /// * device : V4L2 Device to use [default=”/dev/video0″]
    /// * input : V4L2 input to use [default=0]
    /// * standard : Video standard (no-change/PAL/NTSC) [default=”no-change”]
    /// * width : V4L2 width to set [default=-1]
    /// * height : V4L2 height to set [default=-1]
    /// * frameDecimation : Frame decimation factor [default=2]
    /// * sizeDecimation : Size decimation factor [default=8]
    /// * priority : Hyperion priority channel [default=800]
    /// * mode : 3D mode to use 2D/3DSBS/3DTAB (note: no autodetection) [default=”2D”]
    /// * cropLeft : Cropping from the left [default=0]
    /// * cropRight : Cropping from the right [default=0]
    /// * cropTop : Cropping from the top [default=0]
    /// * cropBottom : Cropping from the bottom [default=0]
    /// * redSignalThreshold : Signal threshold for the red channel between 0.0 and 1.0 [default=0.0]
    /// * greenSignalThreshold : SigSignal threshold for the blue channel between 0.0 and 1.0 [default=0.0]
    “grabber-v4l2″ :
    {nal threshold for the green channel between 0.0 and 1.0 [default=0.0]
    /// * blueSignalThreshold :
    “device” : “/dev/video0″,
    “input” : 0,
    “standard” : “no-change”,
    “width” : 640,
    “height” : 480,
    “frameDecimation” : 2,
    “sizeDecimation” : 8,
    “priority” : 1000,
    “mode” : “2D”,
    “cropLeft” : 26,
    “cropRight” : 27,
    “cropTop” :20,
    “cropBottom” : 20,
    “redSignalThreshold” : 0.1,
    “greenSignalThreshold” : 0.1,
    “blueSignalThreshold” : 0.1

      1. yes, the screenshot is perfect but every time I turn on RPI the lights follow the screen KODI and not TV (Set Top Box)

        1. ok, that’s good to hear. Then all you need to do, is to lower the “priority” setting of the v4l2 grabber. Default is 800, the lower the value, the more priority the grabber gets. Try lowering the priority until the grabber is chosen over the xbmcVideoChecker.

          1. thanks, I’ll try it.
            Sorry for my English, I do not speak English very well. I live in Brazil.
            I use WinSCP to tranfereir files between windows and RPI. I deleted the file hyperion.config.json who was in the RPI, but the LED continued to work as before. This is normal?
            What version of OpenElec you use, I’m using the latest version.
            I will try your suggestion.
            Sorry my bad writing.

          2. Did I copied the file to the wrong place. The file is in the / storage / hyperion / config and in the / storage /. I can not find the configfiles folder.

          3. for openelec you have to copy the config file to: /storage/.config/hyperion.config.json then stop and restart hyperion:
            killall hyperiond
            LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperiond /storage/.config/hyperion.config.json

          4. Hello, I managed to make it work. The problem was that I was putting the .json file in the wrong folder. The correct folder is the folder / configfiles. Unfortunately for WinSCP I could not see this folder. I had to enter through windows explorer. Thank you for your help.

  2. I just wanted to say thanks for writing this all up! I mostly have it all working but I’m running into an issue where the crop values are being ignored whenever I take a new screenshot.

    Do you have any pointers on how to fix this?

    Thank you!

    1. Hi Steve, your welcome!
      The parameters in the hyperion.config.json are not taken into account when you take a screenshot. Therefore, you have to add the crop values and all other arguments for the screenshot command to get the same resulto r what do you mean?
      Regards Chris

      1. I use the following totake a screenshot:
        “LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 /storage/.config/hyperion.config.json –screenshot”
        Which does not allow me to change the crop values.

        But when I tried to take a screen shot using what you wrote in the later portion of your tutorial: “// Stop hyperion
        sudo initctl stop hyperion
        // start any HDMI video source and make a screenshot from the grabber input. This will use the external v4l2 grabber
        hyperion-v4l2 –crop-top 0 –crop-bottom 0 –crop-left 0 –crop-right 0 –size-decimator 4 –frame-decimator 2 –red-threshold 0.4 –green-threshold 0.2 –blue-threshold 1.0 –screenshot”

        I get the following error: ” hyperion-v4l2: not found”.

        What is the proper command where I can add in the crop values and other arguments?

        1. Just as I sent my last reply, I had a lightbulb moment! I think I have everything set up and will be doing a first test on the LED’s!

      2. Hi Chris,

        I finally have everything hooked up but I’m running into some problems.

        1) for some reason, only a quarter of my LEDs are on. and it seems like its only the center 20 or so. And the ones that are on are only Red Green and Blue. Any ideas on why this is happening? I’ve already checked the screen shot and it looks good to me.

        2) As mentioned in 1, only part of the LED lights are on and it seems to be the center that are on. I sized my power supply correctly (5v, 10A) and should work with my 153 LEDs.

        Thanks for all the help!

  3. Hey Christian, great guide!

    I’ve managed to create a similar setup of my own. But I have some problems. When I capture a screenshot I get a lot of interference.
    I captured my computer when I only had a chrome window up and a terminal in the bottom right corner. As you can see its a mess of odd colors, which in turn results in flickering of the leds and incorrect colors.

    Do you have any idea what may cause this?

    My setup is like this:
    AVR -> HDMI splitter -> 1 to Projector, 1 to a HDMI to AV converter similar to yours. (—Video-converter—HDMI—black/). Converter -> logilink grabber (STK1160 chipset) -> raspberry running rasbian with hyperion.

    Could it be the grabber? Maybe faulty drivers. I will try to do some debug, checking output in each step.

      1. Yeah, I think I’ll find another grabber with TV007.

        When I checked the composite output after the converter the image was ok, although it had a bit of interference. Maybe I’ll try to find another converter as well.

  4. Hi.
    Great guide, very easy to implement.
    Only issue I’m having is:
    After setting all the cropping using command line:
    “LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 –crop-top 0 –crop-bottom 0 –crop-left 0 –crop-right 0 –size-decimator 4 –frame-decimator 2 –red-threshold 0.4 –green-threshold 0.2 –blue-threshold 1.0 –screenshot”
    and saving to values to /storage/.config/hyperion.config.json I’m trying to take a screenshot using:
    “LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 /storage/.config/hyperion.config.json –screenshot”
    but apparently the values are being ignored…
    Any help would be appreciated.

  5. Hi
    If Im ging to follow all your steps in this and in your First tutorial Can i still use xbmc with the ambilight? So Can i switch the hdmi input between the xbmc Mediacenter and for example my ps3 or an other input?

    1. If you use two rpi, one just for capturing the hdmi signal and one just for the mediacenter then you don’t need to configure hyperion for xbmc as shown in my first tutorial. Just switch the hdmi input and you’re fine.

  6. Hi,
    I have a powered HDMI splitter (should be called a duplicater), but when it is connected to the HDMI to AV converter which in turn is connected to the grabber, itself connected to the Raspberry Pi, the TV signal is downscaled to 480 (from 1080p, 720p or whatever).
    When I disconnect the converter or any piece of the chain, the signal to the TV dinamically reverts back to the original resolution.
    I tested plugging the two outputs from the splitter to the TV, and I get two 1080p signals for instance (switching between HDMI1 and HDMI2 on TV). Again, if I plug the splitter output back to the chain that finishes as 480 AV signal, the HDMI that goes to TV is downscaled…

    I understand the problem comes from the HDMI to AV converter. Can you confirm that the Speaka you have bought lets you have 1080p to the TV while enjoying the leds ?
    I saw that the one you bought costs more than 50€. Mine was the cheapest, 12€. I don’t mine paying more to get a correct one, but 50€ seems too much…


  7. Hi Christian,

    thanks for the post :)

    2 questions though:

    1) When I have this setup configured, what about the HDMI output of the Raspberry? I mean when I watch movies coming from the raspberry pi storage? Where does the hdmi out go?…When I put it in the hdmi in of the hdmi splitter, I would have a loop, don’t I?

    2) What about the TV signal? Does this setup cover the TV signal as well?


    1. Hi Marcus.

      1) Rpi HDMI out to HDMI splitter in, splitter out_1 to TV, splitter out_2 to HDMI2AV.
      2) If you use the built-in decoder of the TV then it won’t be able to grab the signal. For that purpose, you’ll need an external decoder and connect it as shown in 1).

      Regards Christian

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=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">