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|
|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.
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.
2. Hyperion configuration
Hyperion already features capturing color information from a USB video grabber. Add following configuration to your /etc/hyperion.config.json file.
/// 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. The green lines are most likely from the incomplete driver for my grabber.
// 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.
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!