Low-Latency Streaming - AVerMedia Live Gamer HD C985

I'm still on a crusade to solve the problem of having a HDMI output (my Xbox) in one room, while playing it in another room. In my previous article I did all the research I could to find potential solutions to this problem. In this article, I'll run down what I learned from trying to use an HDMI capture card for this purpose.

Eenie, Meenie, Miney, Sale?

I went back and forth on the options I researched. There's a lot of pros and cons to each of them. Some of them I can rule out as just not likely to work (ie, the wife is probably going to balk at drilling holes in the floor of her brand new house). A lot of them I'm having to guess at the latency, because there just isn't good data on the internet about them.

Then there was a sale on the AVerMedia Live Gamer HD C935 capture card, a good $80 off the retail price. I took a deep breath, checked the return policy, and picked one up.

The AVerMedia Live Gamer HD C935

This particular device is a PCIe x1 card with HDMI I/O and analog audio I/O to go with. The card itself can capture 1080p video up to 60 frames per second. It also boasts of a hardware h.264 video encoder, which can offload some of the processing work from your CPU and GPU. This is good for older PCs or if you want to capture a game you're playing on the same PC - the game can use your CPU/GPU while the card does the heavy lifting for streaming.

Also in the box is a USB device that looks like a puck, which you can use to start or stop recording without having some other input to the device.

Installation is simple if you've ever installed an expansion card into a PC before. Power down, put the card into an empty PCIe slot, and power on again.

I skipped the install CD and grabbed the latest drivers, firmware, and whatnot off the AVerMedia site directly. The latest version was from last year, so it doesn't seem like they're actively supporting this card anymore, which is a shame.

In addition to the drivers, the install file includes "AVerMedia RECentral," which is a simple capture and streaming app. In the box with the hardware is a gift code for XSplit, a popular commercial streaming software.

There's also a separate install for something called "Live Gamer HD Stream Engine." It's an optional bit of software that improves compatibility with certain capture applications.

My Capture Rig

I cobbled together some old parts in order to build a rig for this capture card. Given that it's got a hardware encoder on-chip, and that I'm not planning to play and stream with the same machine, I figure I don't need the latest and greatest hardware. We'll see if that comes back to bite me!

The power supply is a 430W, but I'm not running anything crazy here so it should be more than adequate. Likewise, the motherboard is a generic Gigabyte board. The drive is just a stock 7200 RPM SATA drive.

I installed Windows 7 from scratch on the drive, just so that there'd be nothing weird going on from any previous software installations.

This was my gaming rig from several years ago, back when the 8800GT was the card to beat. It's since gone into disuse, as I bought a "gaming" laptop and rebuilt a new desktop in the intervening years.

For the HDMI source, I'm going to use my "gaming" laptop which has HDMI out and a dedicated, switchable ATI GPU.

RTMP Interlude

The intended use of this card is for streaming via the RTMP protocol. Thus, most of the applications designed to use it will want to connect to a RTMP server. This is no big thing if you're connecting to Twitch or similar. However, if you want to stream locally, you'll need a couple of extra pieces of software.

The first is a RTMP server. RTMP is a protocol that was developed as part of Flash, so Adobe and a few other companies make servers that can speak it. However, by and large they're either expensive or slow. We want cheap and fast. Luckily, there is a plugin for nginx that can handle RTMP. nginx is a high-performance web server that is used frequently on Linux as a replacement for Apache. Double luckily, there is a Windows version that includes the RTMP plugin. All you've got to do is download the server, unzip the archive, and set up the RTMP configuration.

I added the following to conf\nginx-win.conf and saved it as conf\nginx.conf:


rtmp {
	buflen 1ms;
	server {
		listen 1935;
        wait_key on;
        wait_video on;
		out_queue 8;
		application stream {
			live on;
			allow publish all;
			allow play all;
		}
	}
}

Note the listen 1935 directive and the application stream block. The listen directive gives the port we will use for both the publisher and the player. The stream name here will be used later in building our RTMP URL as well.

The second is a RTMP client. VLC advertises support for RTMP, but I could not get it working reliably without a lot of latency. I ended up using nginx to serve the open source version of Flowplayer.

[html] <!DOCTYPE html> <html> <head> <!-- 1. skin --> <link rel="stylesheet" href="//releases.flowplayer.org/5.4.6/skin/minimalist.css">

<!-- 2. jquery library --> <script src="//code.jquery.com/jquery-1.10.2.min.js"></script>

<!-- 3. flowplayer --> <script src="//releases.flowplayer.org/5.4.6/flowplayer.min.js"></script> <script src="//releases.flowplayer.org/js/flowplayer-3.2.13.min.js"></script> </head> <body>

<div class="player" id="player" style="height: 1080px;"></div>

<script> $f("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.18.swf", {

            clip: {
                url: 'key',
                provider: 'rtmp',
                live: true,
                bufferLength: 0,
                bufferTime: 0,
            },

            plugins: {
                 rtmp: {
                    url: 'flowplayer.rtmp-3.2.3.swf',
                    netConnectionUrl: 'rtmp://192.168.x.x:1935/stream'
                }
            }
        });

</script>

</body> </html> [/html]

Note the value of url will need to be whatever you set as the "stream key" when you publish your stream using RECentral, OBS, XSplit, etc, in the following sections. The netConnectionUrl uses the IP of the nginx machine, the port from the RTMP plugin given in the config file, and the end of the URL matches the name we gave the RTMP app in the config file as well.

Save this as "player.html" in the nginx directory under the html folder and you should be able to access it after you've started nginx.

Base Software and Latency

To start with, I loaded the included RECentral app and turned on the preview. So far, so good. I put the laptop display in front of the capture rig's monitor, and took a quick pic with my cell phone.

The delta in the two times tells me that the preview is delayed by between 60 and 90 milliseconds, which is 2-3 frames at 30 frames per second. That's pretty darn good, to be honest. Of course, we've still got compression, transmission, and decompression to do.

I started streaming by configuring RECentral to broadcast to the custom RTMP server I set up earlier.

Assuming the setup I discussed earlier, the Stream URL on the Login dialog should be something of the form of:

rtmp://127.0.0.1:1935/stream

Then the stream key can be whatever you want, but it should match the url parameter used for Flowplayer. In my example above, I used key, so I'd put key in the Stream Key blank.

The setup through RECentral to the RTMP server and then to Flowplayer works, but the latency is pretty bad. It's somewhere around 6 seconds, regardless of what encoding settings I choose.

Alternative Software Options

RECentral is the pack-in software for the card, but there are a couple of other major RTMP streaming alternatives. One is the open-source Open Broadcaster Software (OBS) and the other is XSplit.

The downside to using OBS is that the AVerMedia hardware h.264 encoder is proprietary and so OBS doesn't support it. It did help some, getting the latency down to about 2 seconds or so. I couldn't get any better than that, despite trying virtually every parameter the software makes available. The OBS guys don't seem interested in low latency streaming, so it's not really a surprise that it doesn't work as well as I'd want it to.

XSplit is commercial software, but AVerMedia partnered with them to provide a 3-month gift certificate in the box with the capture card. I tried it out, but it didn't seem to lower the latency any more than OBS did. It does, however, work with the hardware h.264 encoder on the card, albeit a bit sloppily and with few options. XSplit has its own "low latency LAN streaming" option, but it's a bloated Java client/server that I couldn't get working properly with my setup. It ate almost 80% of the CPU on the box without really providing any benefit over the nginx RTMP solution I was using elsewhere.

Of course, RTMP isn't the ideal protocol for a low-latency LAN stream of HDMI captured data. There are several places where data could pile up, introducing latency. A point-to-point protocol like RTP might be better. I've been tempted to write my own app that opens the card, encodes the data (or uses the hardware encoder if that's not overly complex) and streams it to some other host on the network. However, the packages I'd normally leverage for this (ie, gstreamer or ffmpeg) don't seem to work properly with the card.

The Verdict

The AVerMedia Live Gamer HD C985 is an odd duck. It purports to encode on the card itself, but only with limited features and only with certain programs. It's clearly not designed for low-latency streaming, but it did get close to doing so. What could the problem be? Maybe it's the capture rig I put together, which is rather old but should be capable of handling the load. It could also be somewhere in software, which I could potentially modify if I had the will and the time.

Overall, I'm bummed that this didn't work out. I may try again with this device or one of the other "long distance HDMI" solutions I've researched. In the meantime, I can at least capture HDMI now, which means that I can screen grab and record stuff for the blog.