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.
|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)|
|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
// List all connected USB devices
// If you're lucky and got a supported STK1160 chipset device, it should list following id:
ID 05e1:0408 Syntek Semiconductor Co., Ltd STK1160 Video Capture Device
// If successfully loaded, your grabber's video input should be found under /dev. For example: /dev/video0
// Remember the output, we'll need it later
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:
curl -L --output install_hyperion.sh --get https://raw.githubusercontent.com/tvdzwan/hyperion/master/bin/install_hyperion.sh
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:
LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperiond /storage/.config/hyperion.config.json
Take a screenshot from the grabber with following command. Remember to kill hyperiond before you can execute this command properly!
LD_LIBRARY_PATH=/storage/hyperion/bin /storage/hyperion/bin/hyperion-v4l2 /storage/.config/hyperion.config.json --screenshot
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.
/// 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 : Signal threshold for the green channel between 0.0 and 1.0 [default=0.0]......
/// * blueSignalThreshold : Signal threshold for the blue channel between 0.0 and 1.0 [default=0.0]
"device" : "/dev/video0",
"input" : 0,
"standard" : "no-change",
"width" : 1,
"height" : 1,
"frameDecimation" : 2,
"sizeDecimation" : 4,
"priority" : 800,
"mode" : "2D",
"cropLeft" : 10,
"cropRight" : 8,
"cropTop" : 12,
"cropBottom" : 19,
"redSignalThreshold" : 0.4,
"greenSignalThreshold" : 0.2,
"blueSignalThreshold" : 1.0
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!
// 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
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.
// After you have checked the screenshots and configured your cropping values, start hyperion with the internal v4l2 grabber again
sudo initctl start hyperion
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.
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!