How should I encode content for Google TV using HLS?
Asked Answered
C

1

15

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?

Contemporary answered 19/4, 2012 at 14:38 Comment(0)
C
26

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

Contemporary answered 19/4, 2012 at 14:58 Comment(4)
Nice overview. Is there a way to specify the headers to be sent when the media player makes the HTTP request for the individual video segments? I'm assuming not, since the following method is only available in API level 14:developer.android.com/reference/android/media/…, android.net.Uri, java.util.Map<java.lang.String, java.lang.String>).Mechanical
You can look for that method via reflection on Google TV and use it.Contemporary
Genius!! It worked. Thank you very much. That deserves a +1. :)Mechanical
@LesVogel-GoogleDevRel: I have a similar issue, can you please take a look at my question? #22318365Bedevil

© 2022 - 2024 — McMap. All rights reserved.