NGINX for Commercial Quality Streaming Services Seungyeob Choi Manager, Software Engineering Verizon Digital Media Services

Similar documents
Internet Networking recitation #13 HLS HTTP Live Streaming

Dolby Vision. Streams within the MPEG-DASH format

HTTP STREAMING DASH MPEG-DASH ISO/IEC G Madec information issued from standard documentation and reference CF end

Widevine DRM for HLS. version 0.9

Chapter 28. Multimedia

HYBRID BROADCAST AND OTT DELIVERY FOR TERRESTRIAL AND MOBILE TV SERVICES

Comparing Adaptive HTTP Streaming Technologies

Lec 16 Multimedia Systems II: DASH Advanced Features

HTTP Adaptive Streaming

Streaming Technologies Delivering Multimedia into the Future. May 2014

ADAPTIVE STREAMING AND CONVERGED MANAGEMENT STRATEGY IN MULTISCREEN VIDEO SERVICE IMPLEMENTATION Duncan Potter, Goran Appelquist Edgeware AB

INTERNATIONAL ORGANISATION FOR STANDARDISATION ORGANISATION INTERNATIONALE DE NORMALISATION ISO/IEC JTC1/SC29/WG11 CODING OF MOVING PICTURES AND AUDIO

HTTP Based Adaptive Streaming over HSPA

Live HTTP Streaming of Video and Subtitles within a Browser

Adaptive HTTP Streaming and the MPEG-DASH standard

EZDRM Integration NGINX Kaltura VOD Module

Adaptive Video Acceleration. White Paper. 1 P a g e

EZDRM Service Integration Into Kaltura CE with Nginx

TBS8510 Transcoder Server User Guide

Mobile Cloud Computing & Adaptive Streaming

ADAPTIVE STREAMING AT. Justin Ruggles Lead Engineer, Transcoding & Delivery

TBS8520 Transcoder Server User Guide

DECLARATION OF ALEXA MORRIS. I, Alexa Morris, hereby declare under penalty of perjury:

Encoding and Packaging. version 1.1

ADDRESSING IP VIDEO ADAPTIVE STREAM LATENCY AND VIDEO PLAYER SYNCHRONIZATION JEFFREY TYRE - ARRIS WENDELL SUN - VIASAT

Dolby Vision. Streams within the HTTP Live Streaming format

MODELING REAL-TIME MULTIMEDIA STREAMING USING HLS PROTOCOL

Important Encoder Settings for Your Live Stream

A Converged Content Delivery Platform for IP and QAM Video

MIUN HLS Player - Proof of concept application for HTTP Live Streaming in Android 2.3 (October 2011)

Title: Scalable Video Coding based DASH for efficient usage of network resources

Live Streaming: Why Transcoding is so Cri7cal to Quality. Ryan Jespersen Training Manager Wowza Media Systems

Page 1. Outline / Computer Networking : 1 st Generation Commercial PC/Packet Video Technologies

DVS-200 Configuration Guide

Vantrix Corporation VTA Developer Guide

DVS-100P Configuration Guide

Internet Video Delivery. Professor Hui Zhang

Algorithms and Formats for Adaptive Streaming

ADAPTIVE STREAMING. Improve Retention for Live Content. Copyright (415)

Orchestrate Video MMD Live Guide

IMPROVING LIVE PERFORMANCE IN HTTP ADAPTIVE STREAMING SYSTEMS

HIGH PERFORMANCE VIDEO CODECS

Encoding At Netflix Media Meetup, May 2014 Netflix Digital Supply Chain

AWS Elemental MediaPackage API Reference. API Reference

SubTech 1. Short intro on different subtitle standards ISOBMFF, MPEG-DASH, DVB-DASH, DASH-IF, CMAF, HLS

End-to-end IPTV / OTT Solution

ProMedia TM Xpress. (Xpress Preset and Package Preset) User Guide RELEASE Rev A

The Effect of Client Buffer and MBR Consideration on DASH Adaptation Logic

DVS-200 Configuration Guide

DOCUMENT TITLE. FFMPEG RTMP TO AWS ELEMENTAL MEDIALIVE TO AWS ELEMENTAL MEDIAPACKAGE Workflow Example

Interoperability Quest: OTT Video, WebApps and CE

A Joint SLC/RealEyes Production.

A TV platform jelen kihívásai és a fejlődés iránya. Horváth Ede 2017 October 05.

Introduction. Input Format Support

KALEIDO MULTIVIEWER Product Comparison Guide

Study of video streaming standards

MULTISCREEN DELIVERY SOLUTION

Adaptive Bitrate Streaming

Anatomy of a DASH Client. Ali C. Begen, Ph.D.

AWS Elemental MediaLive. User Guide

Streaming. Adaptive. a brief tutorial. Niels Laukens VRT Medialab

irtc: Live Broadcasting

2016 Spring Technical Forum Proceedings

How Libre can you go?

Universal Ad Package (UAP)

Achieving Low-Latency Streaming At Scale

Distributed DASH Dataset

AWS Elemental MediaPackage. User Guide

Revision 4.1.x /2.x.x [ ] Creating Media for Modulo Player & Kinetic

MULTISCREEN DELIVERY SOLUTION

Contents. About Objective Quality Benchmarks 15 Overview of Objective Benchmarks and Tools 16

Video. Add / edit video

AWS Elemental MediaConvert. User Guide

How to Connect the Sony SRG-300SE to WOWZA Streaming Engine

PRODUCT DESCRIPTIONS AND METRICS

Lecture 27 DASH (Dynamic Adaptive Streaming over HTTP)

About MPEG Compression. More About Long-GOP Video

IRENIS HDE-265 HDMI Encoder User s Manual Introduction

Wowza ndvr. User's Guide

Request for Comments: 8216 Category: Informational. August 2017

Cisco Virtual Media Packager User Guide

Evaluation and simulation of Video using EvalVid Tool

Ezserver Signage User Guide

EvoStream Media Server How To

Information technology Dynamic adaptive streaming over HTTP (DASH) Part 1: Media presentation description and segment formats

Clipping media using a script for Windows (and Linux)

Emulation of Dynamic Adaptive Streaming over HTTP with Mininet

H.264 DASH HLS. Azure Media Services

Cobalt Digital Inc Galen Drive Champaign, IL USA

Remote Control the Robin. How-To: ROBIN Tech Note. Version: Robin NL Datum:

TotalCode Enterprise is an ideal solution for video-on-demand content preparation for any screen anywhere.

ADVERTISING SPECIFICATION

HDMI/HD-SDI HEVC/H.264 IPTV

2015 / 11/ 11 Version 1.6

4K Video Processing and Streaming Platform on TX1

Full HD HEVC(H.265)/H.264 Hardware IPTV Encoder Model: MagicBox HD4 series MagicBox HD401: Single channel HDMI/AV, HDMI/VGA/YPbPr/AV, HDSDI input

FFmpeg Bitstream Filters Documentation

Video Developer Report 2017

Offline. VersAtive Offline Transcoding for VOD & File/Storage-based Video Applications: Introduction: Applications: Product Line Overview:

Measuring Over-the-Top Video Quality

Transcription:

NGINX for Commercial Quality Streaming Services Seungyeob Choi schoi@verizon.com Manager, Software Engineering Verizon Digital Media Services Verizon 2016 All Rights Reserved. Information contained herein is provided AS IS and subject to change without notice. All trademarks used herein are property of their respective owners. 1

Agenda 1. Introduction to streaming 2. Turn NGINX into a streaming server 3. HLS/DASH VOD by NGINX How? 4. Supporting HLS 7 5. Encrypting HLS 6. High-bitrate streaming (4K/8K UHD) by NGINX 7. Low-latency live by NGINX 2

Introduction to Streaming 3

Streaming by HLS & MPEG-DASH HLS and MPEG-DASH are the two most widely accepted formats. The content is divided to small chunks, each containing a few seconds of video/audio. A playlist file provides the list of all chunks. Playlist and chunks can either be pre-processed, or be prepared upon request. 4

Pre-packaging to HLS using ffmpeg ffmpeg -i video.mp4 -codec copy -vbsf h264_mp4toannexb -f segment -segment_list video.m3u8 -segment_time 10 -segment_format mpeg_ts -segment_list_type m3u8 video%04d.ts MP4 video.m3u8 #EXTINF:10, video0000.ts #EXTINF:10, video0001.ts #EXTINF:10, video0002.ts #EXTINF:10, video0003.ts List all segments of 10 seconds Cut mp4 into a 10 second segment and repackage in MPEG2 TS format..ts.ts.ts 5

Pre-packaging to MPEG-DASH using gpac (MP4Box) MP4Box -dash 10000 rap -out video.mpd -segment-name video_ video.mp4 video.mpd <SegmentURL media="video_1.m4s"/> <SegmentURL media="video_2.m4s"/> <SegmentURL media="video_3.m4s"/> <SegmentURL media="video_4.m4s"/> <SegmentURL media="video_5.m4s"/> <SegmentURL media="video_6.m4s"/> List all segments of 10 seconds MP4.m4s.m4s.m4s Cut mp4 into a 10 second segment and repackage in fragmented-mp4 format. 6

Turn NGINX to a streaming server 7

Download and install NGINX RTMP module Developed by Roman Arutyunyan Git: https://github.com/arut/nginx-rtmp-module Blog: http://nginx-rtmp.blogspot.com/ sudo apt-get install -y unzip build-essential libpcre3 libpcre3-dev libssl-dev cd /opt wget http://nginx.org/download/nginx-1.10.1.tar.gz wget https://github.com/arut/nginx-rtmp-module/archive/master.zip tar -zxvf nginx-1.10.1.tar.gz unzip -o master.zip cd nginx-1.10.1./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master make make install 8

HLS Live A live application can have HLS mode on. HLS playlist (.m3u8) and segment (.ts) files are generated in real time from ingested stream. rtmp { server { application mylive { live on; hls on; hls_path /usr/local/nginx/html/hls; hls_fragment 10s; } } } 9

DASH Live A live application can have DASH mode on. DASH playlist (.mpd) and segment (.m4v and.m4a) files are generated in real-time from ingested stream. rtmp { server { application mylive { live on; hls on; hls_path /usr/local/nginx/html/hls; hls_fragment 10s; } } } dash on; dash_path /usr/local/nginx/html/dash; dash_fragment 10s; 10

VOD streaming by NGINX Plus hls directive turns on dynamic HLS segmentation. NGINX Plus can prepare HLS manifest (.m3u8) and segment (.ts) files on the fly. http { server { application myhls { hls; hls_fragment 10s; } } } f4f directive turns on HDS mode. NGINX Plus can prepare HDS manifest (.f4m) and segments. But, mp4 file needs to be pre-processed to f4f using Adobe s f4fpackager. Not much benefit if compared with prepackaging. http { server { application myhds { f4f; } } } 11

HLS/DASH VOD by NGINX - How? 12

How to segment ffmpeg ss 0 itsoffset 0 i video.mp4 t 10 codec copy I P P P P segment1.mp4 I P P P P I P P P P I P P P P I P P P P I P P I P P P P 10s 10s 20s 20s 30s 40s ffmpeg ss 10 itsoffset 10 i video.mp4 t I P 20 P codec copy P P segment2.mp4 ffmpeg ss 20 itsoffset 20 i video.mp4 t 30 codec copy segment3.mp4 30s 13

In reality Can t play! P P P I P I P P P P P P P I P P P I P P I P P P P P I P P I P P P P 10s 20s 20s 30s 40s 10s Can t! P P I P P 30s 14

Then, how to cut real mp4? ffmpeg ss 0 itsoffset 0 i video.mp4 t 17 codec copy segment1.mp4 I P P P P P P P I P P P I P P P P P P P I P P P I P P I P P P P P I P P 24s Key frame location is unpredictable. Segment duration is unpredictable. Need to get key frame locations in advance before ffmpeg ss 17 itsoffset 17 i video.mp4 t 24 ffmpeg ss 24 itsoffset 24 codec copy I P P i video.mp4 t 30 segment2.mp4 cutting segments. codec copy segment3.mp4 17s 30s 15

The art of getting segment boundaries I P P P P P P P I P P P I P P I P P P P P I P P Get the location of key frames 17s 24s 30s 43s ffprobe -select_streams v -skip_frame nokey -show_frames -v quiet video.mp4 grep '^pkt_pts_time sed 's/pkt_pts_time=//' 0.000000 17.000000 24.000000 30.000000 43.000000 16

Generate HLS playlist The playlist can be generated from a template using key frame locations. Template #EXTM3U #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-ALLOW-CACHE:YES #EXT-X-TARGETDURATION:sizeof($N) FOR EACH $N[i] { #EXTINF:($N[i+1] $N[i]), $file.$n[i].ts Segment boundaries $N={ 0.000000, 17.000000, 24.000000, 30.000000, 43.000000, } File name } $file= video.mp4 video.mp4.m3u8 #EXTM3U #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-ALLOW-CACHE:YES #EXT-X-TARGETDURATION:10 #EXTINF:17.000000, video.mp4.0.000000.ts #EXTINF:7.000000, video.mp4.17.000000.ts #EXTINF:6.000000, video.mp4.24.000000.ts #EXTINF:13.000000, video.mp4.30.000000.ts #EXTINF:8.000000, video.mp4.43.000000.ts 17

Generate HLS segment I P P P P P P P I P P P I P P I P P P P P I P P ffmpeg ss 17 itsoffset 17 i video.mp4 t 24 codec copy segment2.mp4 I P P P video.mp4.17000.ts MP2TS ffmpeg i segment2.mp4 -codec copy -vbsf h264_mp4toannexb -flags -global_header -segment_format mpegts segment2.ts 18

DASH playlist and segment Segment boundaries $N={ 0.000000, 17.000000, 24.000000, 30.000000, 43.000000, } <MPD type="static" xmlns="urn:mpeg:dash:schema:mpd:2011 profiles="urn:mpeg:dash:profile:isoff-on-demand:2011 minbuffertime="pt1.5s mediapresentationduration="pt0h0m40s"> <Period start="pt0s" duration="pt0h0m40s"> <AdaptationSet segmentalignment="true" bitstreamswitching="true"> <Representation id="avc1:9938805 mimetype="video/mp4" codecs="avc1.42c01e width= 640" height= 264 startwithsap="1" bandwidth= 144000"> <SegmentTemplate presentationtimeoffset="0" timescale="1000 initialization= video.mp4.m4v" media= video.mp4+$time$.m4v"> <SegmentTimeline> <S t="0" d= 17000"/> <S t= 17000" d= 7000"/> <S t="24000" d= 6000"/> <S t= 30000" d= 13000"/>... video.mp4.mpd Template... </SegmentTimeline> </SegmentTemplate> </Representation> </AdaptationSet> 19

Track split and repackage (MP4Box) Most DASH players don t like video and audio tracks combined in a single segment. ffmpeg -itsoffset 17 -i segment2.mp4 -vcodec copy an segment2.video.mp4 MP4 Video only M4V MP4Box -noprog quiet -dash 10000 -single-segment rap -out video_temp.mpd -segment-name segment_ segment2.m4v MP4 ffmpeg -itsoffset 17 -i segment2.mp4 -vn -acodec copy segment2.audio.mp4 MP4 Audio only M4A MP4Box -noprog quiet -dash 10000 -single-segment rap -out video_temp.mpd -segment-name segment_ segment2.m4v 20

Supporting HLS 7 and up 21

HLS 7 revision 20 What s new? HLS now support segments in fmp4. Can share segments with MPEG-DASH and Microsoft Smooth Streaming. Can split video and audio (multiple audio tracks are now cheaper than before). Can save CPU and storage! Master playlist is now mandatory, even if the stream is a single-bitrate. 22

Playlist format HLS 3 Playlist #EXTM3U #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=10130832,CODEC="avc1.640033,mp4a. 40.2",RESOLUTION=3840x2160 vide.mp4_1.m3u8 #EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP- ID="cc1",LANGUAGE= en",name= English",AUTOSELECT=YES,DEFAULT=YES,INSTREAM-ID="CC1" #EXTM3U #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:1 #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-ALLOW-CACHE:NO #EXT-X-TARGETDURATION:12 #EXTINF:10.677, vide.mp4+0.ts #EXTINF:9.801, vide.mp4+10677.ts #EXTINF:9.551, vide.mp4+20478.ts #EXTINF:11.261, vide.mp4+30030.ts #EXTINF:10.344, vide.mp4+41291.ts #EXTINF:8.425, vide.mp4+51634.ts #EXT-X-ENDLIST HLS 7 Master playlist HLS 7 Media playlist #EXTM3U #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:1 #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-INDEPENDENT-SEGMENTS #EXT-X-MAP:URI="1.mp4" #EXT-X-TARGETDURATION:12 #EXTINF:10.67733, 1+0.mp4 #EXTINF:9.80146, 1+512512.mp4 #EXTINF:9.55121, 1+982982.mp4 #EXTINF:11.26125, 1+1441440.mp4 #EXTINF:10.34367, 1+1981980.mp4 #EXTINF:8.42508, 1+2478476.mp4 #EXT-X-ENDLIST 23

Segments HLS 3 MPEG2 TS HLS 7 Video Audio Video Audio Video Audio Fragmented MP4 Video Audio Video Audio Video Audio 24

How to support HLS 7 r20 using NGINX RTMP #EXTM3U HLS 7 Segments #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=10130832,CODEC="avc1.640033,mp4a. 40.2",RESOLUTION=3840x2160 vide.mp4_1.m3u8 #EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP- ID="cc1",LANGUAGE="xx",NAME="Undefined",AUTOSELECT=YES,DEFAULT=YES,INSTREAM-ID="CC1" HLS 7 Master playlist HLS 7 Media playlist #EXTM3U #EXT-X-VERSION:7 #EXT-X-MEDIA-SEQUENCE:1 #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-INDEPENDENT-SEGMENTS #EXT-X-MAP:URI="1.mp4" #EXT-X-TARGETDURATION:12 #EXTINF:10.67733, 1+0.mp4 #EXTINF:9.80146, 1+512512.mp4 #EXTINF:9.55121, 1+982982.mp4 #EXTINF:11.26125, 1+1441440.mp4 #EXTINF:10.34367, 1+1981980.mp4 #EXTINF:8.42508, 1+2478476.mp4 #EXT-X-ENDLIST Create by rules Convert from DASH mpd Reuse DASH segments Video Video Video Audio Audio Audio 25

Encryptin g HLS 26

Protecting HLS How does it work? Playlist If a key is specified Key Segment Decrypt using the key 27

Protecting HLS How to make it work? #EXTM3U #EXT-X-VERSION:7 #EXT-X-KEY:METHOD=AES-128,URI= video.key",iv=0x00000000000000000000000000000000 #EXT-X-MEDIA-SEQUENCE:1 #EXT-X-PLAYLIST-TYPE:VOD #EXT-X-INDEPENDENT-SEGMENTS #EXT-X-MAP:URI="1.mp4" #EXT-X-TARGETDURATION:12 #EXTINF:10.67733, 1+0.mp4 #EXTINF:9.80146, 1+512512.mp4 #EXTINF:9.55121, 1+982982.mp4... openssl enc -aes-128-cbc -in original.mp4" -K video.key" -p -iv 0 -out encrypted.mp4" 28

High-bitrate streaming (4K/8K UHD) by NGINX 29

4K/8K UHD How big are they? When horizontal and vertical resolutions are doubled, the amount of data are quadrupled. As a result, the number of pixels are growing exponentially in bigger resolution. SD 640x480 = 300K pixels. HD 1280x720 = 900K pixels (3x SD) UHD 4096x2160 = 8.44M pixels (9.4x HD, 28x SD) 30

Vimeo recommendation https://vimeo.com/help/compression Quality Bitrate (Mbps) SD 2-5 720p 5-10 1080p 10-20 2K 20-30 4K 30-60 8K 50-80 31

Optimization for smooth 4K/8K experience Segment duration Key frame interval Multi-bitrate Network optimization HEVC/H.265 2-4 seconds is recommended. Longer segments require longer initial start up (e.g. 10 second Many segment clients from can t 12Mbps video is process 15MB, Make while sure UHD 2 to data. second connect segment is (Roughly) 3MB) to edge/cache half-sized servers data for the same close quality, to or the (also client. roughly) twice quality from the same bitrate. 32

Low-latency live streaming by NGINX 33

Low latency live Why is it a such big challenge? HTTP-based streaming was originally not designed for live streaming. Encoder buffer Ingest/playlist latency Delivery latency Player buffer Total 45-60 seconds? 34

Optimization for sub-10 seconds latency Smaller segment duration (2-3 seconds) Shorter key frame interval Smaller playlist window (3x segment) Network optimization Chunk Transfer Encoding Segments start being sent before they are complete. The smaller, the better, but should not be too small. (Too small segments make the Player buffer player is beyond to fail to make up after control. We a short can enforce network disturbance.) it to be small, by a small playlist window. 35

Thank you. 36 3