Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I encode content for Google TV using HLS?

HLS is a feature of Google TV 3.2, what's the best way to encode my content to be viewed on a Google TV?

like image 305
Les Vogel - Google DevRel Avatar asked Apr 19 '12 14:04

Les Vogel - Google DevRel


People also ask

Should I use youtube RTMP or HLS?

RTMP is no longer the standard for live video streaming, but it's still used behind the scenes and has a place in the process. As Mediastream rightly explains, "RTMP is the most widely used protocol for ingesting and HLS for playback. The latter is the most recommended by the company; its delivery is segmented.

What is HLS video format?

HLS format is an adaptive bitrate live streaming video protocol. Originally developed by Apple for use on iOS, Mac OS, and Apple TV devices, HLS streaming has become the most widely used live video protocol.

Is HLS a codec?

HLS will play video encoded with the H. 264 or HEVC/H. 265 codecs. The HTTP server also creates an M3U8 playlist file (e.g. manifest file) that serves as an index for the video chunks.

When should we use HLS?

If you want to cast to mobile devices and tablets, HLS is mandatory. Since mobile devices now account for the majority of Internet traffic (about 75% of traffic in 2019), HLS is essential. Native HTML5 videos are not compatible with RTMP or HDS.


1 Answers

How to Implement HLS for Google TV

Http Live Streaming aka HLS is a standard for streaming multimedia content (Audio and Video) supported by Google TV.

There are many cool features that come with HLS. The main ones are:

  1. Adaptive Streaming - Automatically adapts to either congestion or bandwidth availability.
  2. Resilience to transient network failures.
  3. No special configuration for your server, routers, or firewalls. It’s just HTTP 1.1
  4. Easily supported by Content Delivery Networks
  5. Live streaming is supported (more in a longer article)
  6. HTML5 video tag support in Chrome for Google TV.
  7. Optional AES encryption (more in a longer article).

On Google TV, HLS is a standard protocol, you just put your url in any of the Media Playback API’s such as MediaPlayer, VideoView, etc. It just works.

Components of a HLS file

.m3u8 - Text based manifest or playlist file (may be updated for live content) - a variant playlist usually points to individual manifests that also end in .m3u8 MIME Type: vnd.apple.mpegURL or application/x-mpegURL

.ts - MPEG 2 Transport Stream - Typically 5-10 seconds long video & audio data. MIME Type: video/MP2T

Creating content for HLS

The easiest way to create HLS content is to use Apple’s tools, the latest version of Sorenson Squeeze, Telestream’s Episode, and many cloud encoding providers. You start with content you encode at many bit rates. For Google TV, the first line in the .m3u8 file is the speed we start with. It’s probably best to pick the 1.2mbps stream.

Google TV supports HLS protocol version 3 as of Google TV firmware version 3.2.

Your content URL’s must have the characters “.m3u8” within the URL. If the URL doesn’t end with “.m3u8”, the system will make at least 2 requests before playback and the MIME type of the playlist must be one of “application/vnd.apple.mpegurl” or “application/x-mpegurl”.

Note - Google TV doesn’t currently support codec switching - so Ad segments must use the same encoding as the main content. Of course, developers can pause the HLS playback, play some other content, then resume the HLS playback again to get around this.

Encoding

Encoding content is as much an art as it is a science. The best choices are very much dependent on your content, what speed objects move against the background, and many other items that are too numerous to go into a simple post. It is also dependent on the devices you are targeting. The settings below are designed to be optimized for Google TV. Older devices may require different / additional encodings. Be aware that certain types of encoding for commercial purposes may require a license and/or the payment of royalties.

Audio Encoding should be consistent across all streams. HE-AACv1, HE-AACv2, AAC-LC up to 48kHz, stereo audio are all acceptable choices.

16:9 Aspect Ratio**
             Total  Video
Dimensions Bitrate Bitrate Encoding
640x360        640     600 HiP, 4.1
640x360       1240    1200 HiP, 4.1
960x540       1840    1800 HiP, 4.1
1280x720      2540    2500 HiP, 4.1
1280x720      4540    4500 HiP, 4.1
1920x1080     6040    6000 HiP, 4.1
1920x1080     8196    8156 HiP, 4.1


4:3 Aspect Ratio
             Total  Video
Dimensions Bitrate Bitrate Encoding
640x480        640     600 HiP, 4.1
640x480       1240    1200 HiP, 4.1
960x720       1840    1800 HiP, 4.1
1280x960      2540    2500 HiP, 4.1
1280x960      4540    4500 HiP, 4.1

Keyframe

The current Google TV implementation only uses the Keyframe at the beginning of each segment (For a 10 second segment at 30fps this would be every 300 frames). The Apple suggestion is to have a Keyframe every 90 frames. (or every 3 seconds at 30fps) Note - Framerate is a complex subject.

** Adapted from https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices

like image 102
Les Vogel - Google DevRel Avatar answered Nov 10 '22 04:11

Les Vogel - Google DevRel