Live streaming

From Real Vegan Cheese
Revision as of 08:04, 9 September 2014 by Juul (talk | contribs) (Created page with " Live streaming currently uses flash on the client and the RTMP protocol for content. This may change in the future, but for now that's how the professional content providers ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Live streaming currently uses flash on the client and the RTMP protocol for content. This may change in the future, but for now that's how the professional content providers do it. The only live output from most cameras is HDMI (more high end rigs use SDI). The two main challenges in live-streaming is:

  • Converting the HDMI signal to an H.264 encoded RTMP output.
  • Serving the RTMP stream to multiple simultaneous clients.

We will need to deal with two simultaenous HDMI streams:

  • One of the scene (lecturer, meeting, event)
  • A secondary stream for e.g. streaming the output from the presenter's computer

The secondary stream must accept all of the weird laptop output signals people use: HDMI, DVI, VGA, DisplayPort, Thunderbolt and Apple weirdness.

Encoding (HDMI to RTMP)

There are three basic ways of tackling encoding:

  • Use a dedicated piece of hardware strapped to the camera
  • Use a camera with built-in encoding and RTMP output
  • Use an HDMI input device hooked up to a normal computer (software encoding)

Dedicated encoders

These are all encoders that can take a HDMI input, encode it using H.264 and send an RTMP stream over ethernet to a user-specified RTMP server. Some or all of these may rely on cloud services to be configured (need to investigate).

  • Teradek VidiU - $700
    • Up to 1080p
  • Cerevo LiveShell - $250
    • SD quality only
  • Cerevo LiveShell Pro - $700
    • Up to 720p

The following products are vendor-locked so you cannot use them with your own RTMP server:

  • Livestream Broadcaster - $500
    • Up to 720p

Cameras with built-in encoders

There are two options here:

  • The Raspberry Pi with the Raspberry Pi camera
  • A camcorder with built in wifi streaming.

The Raspberry Pi is actually pretty amazing. Its built-in encoding + the fact that it runs linux means that it has amazing flexibility. On top of that it is super cheap. Unfortunately the only camera available doesn't have a very high quality sensor. It doesn't come with any decent optics, so you have to basically build a camera house and add your own optics, but that can all be 3D printed, and at a price of less than $70 for computer, camera and sd card, it's really hard to beat!

The camcorder option is a bit iffy, both because wifi on 2.4ghz at a conference-type event is likely to be bogged down, and because it's unclear if any of these camcorders allow you to stream to your own RTMP server (I doubt it).

Software encoding

With software encoding on a normal computer there are three concerns:

  • Getting the HDMI output from the camera to the computer
  • Getting the HDMI signal into a normal computer
  • Having enough IO and CPU power to real-time encode H.264 content.

Getting the HDMI signal to the computer

You can get active cables from RedMere that can run HDMI up to 60 feet:

HDMI ports are not the best for a production environment. It is easy to accidentally unplug the cables or pull them sideways in a way that ruins the plug or port. We can likely use a moldable plastic like InstaMorph to make the HDMI plugs hard to remove or break.

Another solution is to convert HDMI to the more professional SDI at the camera.

SDI cable seems to be similarly priced to HDMI cable.

Getting the HDMI signal into a normal computer

Black Magic Design has a few different devices for getting HDMI into a computer. One device is USB3 for windows and another is Thunderbolt for Mac. There are also other cheaper products like the Hauppauge HD PVR 2 which also does encoding, but none of these devices are supported in Linux :(

The only device with HDMI input and linux support seems to be the Black Magic Design DeckLink Mini Recorder which is a PCI Express card. At $145 it is fairly cheap, but the computer needed to do the encoding would probably cost at least another $500, meaning that it ends up costing the same as dedicated encoder hardware.

Encoding content

Using ffmpeg and x264 encoding is easy and gives full control over all encoding parameters.

Serving the RTMP stream

The server simply accepts an incoming RTMP stream and forwards to every client that connects. This can be run on a VPS.

Hardware and bandwidth

A VPS with 100 mbit unlimited bandwidth (enough for ~80 simultaneous dvd-quality stream) is only $17 per month.

Compare to $99 per month for 100 ad-free viewer hours.


The RTMPd server is also fairly easy to use, and Red5 is another open source option (but it's java based and I think it kinda sucks).


RTMP is nice because an RTMP stream can contain arbitrary actionscript objects that are time-synchronized, providing the ability for slide change events, chat transcripts or annotations to be saved as part of the stream and replayed.