NGINX For Commercial Quality Streaming Services

3y ago
141 Views
2 Downloads
489.42 KB
36 Pages
Last View : 5d ago
Last Download : 9m ago
Upload by : Oscar Steel
Transcription

NGINX forCommercial QualityStreaming ServicesSeungyeob Choi schoi@verizon.comManager, Software EngineeringVerizon 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

Agenda1. Introduction to streaming2. Turn NGINX into a streaming server3. HLS/DASH VOD by NGINX – How?4. Supporting HLS 75. Encrypting HLS6. High-bitrate streaming (4K/8K UHD) by NGINX7. Low-latency live by NGINX2

Introductionto Streaming3

Streaming byHLS & MPEG-DASH HLS and MPEG-DASH are the two most widelyaccepted formats. The content is divided to small chunks, eachcontaining 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 ffmpegffmpeg -i video.mp4 -codec copy-vbsf h264 mp4toannexb-f segment-segment list video.m3u8-segment time 10-segment format mpeg ts-segment list type m3u8video%04d.tsvideo.m3u8List all segmentsof 10 .ts#EXTINF:10,video0002.ts#EXTINF:10,video0003.ts Cut mp4 into a 10second segmentand repackage inMPEG2 TS format.MP4.ts.ts.ts 5

Pre-packaging to MPEG-DASH using gpac (MP4Box)MP4Box -dash 10000 –rap-out video.mpd-segment-name videovideo.mp4video.mpd SegmentURL SegmentURL SegmentURL SegmentURL SegmentURL SegmentURLmedia "video 1.m4s"/ media "video 2.m4s"/ media "video 3.m4s"/ media "video 4.m4s"/ media "video 5.m4s"/ media "video 6.m4s"/ List allsegments of10 secondsCut mp4 into a 10second segmentand repackage infragmented-mp4format.MP4.m4s.m4s.m4s 6

Turn NGINXto a streamingserver7

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-devcd /optwget http://nginx.org/download/nginx-1.10.1.tar.gzwget master.ziptar -zxvf nginx-1.10.1.tar.gzunzip -o master.zipcd nginx-1.10.1./configure --with-http ssl module --add-module ./nginx-rtmp-module-mastermakemake install8

HLS Live A live application can have HLS mode on. HLS playlist (.m3u8) and segment (.ts) files are generated in real time fromingested 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-timefrom 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 f4f directive turns on HDS mode. hls directive turns on dynamicHLS segmentation. NGINX Plus can prepare HDS manifest(.f4m) and segments. NGINX Plus can prepare HLSmanifest (.m3u8) and segment(.ts) files on the fly. But, mp4 file needs to be pre-processed tof4f using Adobe’s f4fpackager. Not much benefit if compared with prepackaging.http {server {application myhls {hls;hls fragment 10s;}}}http {server {application myhds {f4f;}}}11

HLS/DASHVOD byNGINX- How?12

How to segmentffmpeg –ss 0 –itsoffset 0–i video.mp4 –t 10–codec copy I P P P Psegment1.mp4I P P P P IIP P P P20s10sP P P P10sIP P P P20sffmpeg –ss 10 –itsoffset 10–i video.mp4 –tI P20 P P P–codec copysegment2.mp4IP P P P30sIP P 40sffmpeg –ss 20 –itsoffset 20–i video.mp4 –t 30–codec copysegment3.mp430s13

In reality Can’tplay!IIP P P I PP P P P P P P20s10sP P P PIP P PIP P20sP PIIP P P P P30sIP P 40sP P10sCan’t!30s14

Then, how to cut real mp4?I P P PI P P P P P P Pffmpeg –ss 0 –itsoffset 0–i video.mp4 –t 17–codec copysegment1.mp4IP P PI24sIP P P P P P Pffmpeg –ss 17 –itsoffset–i video.mp4 –t 24–codec copy I P Psegment2.mp417sP P I P P P P P IP P Key frame location isunpredictable. Segment duration isunpredictable.17 Need to get key frameffmpeg locations–ss 24 –itsoffsetin advance24 before–icuttingvideo.mp4–t 30segments.–codec copysegment3.mp430s15

The art of getting segment boundariesIGet thelocation ofkeyframesP P P P P P PIP P P17sIP P24sIP P P P P30sffprobe -select streams v -skip frame nokey-show frames -v quiet video.mp4 grep ' pkt pts time’ sed 's/pkt pts time //'IP P 43s0.00000017.00000024.00000030.00000043.000000 16

Generate HLS playlist The playlist can be generated from a template using key frame #EXT-X-TARGETDURATION:sizeof( N)FOR EACH N[i] {#EXTINF:( N[i 1] – N[i]), file. N[i].ts}Segmentboundaries N {0.000000,17.000000,24.000000,30.000000,43.000000, }File name file 00000.ts#EXTINF:8.000000,video.mp4.43.000000.ts 17

Generate HLS segmentIPPPPPPPIPPPffmpeg –ss 17 –itsoffset 17–i video.mp4 –t 24–codec copysegment2.mp4IPPIPPPPPIPP video.mp4.17000.tsIPPPMP2TSffmpeg –i segment2.mp4 -codec copy-vbsf h264 mp4toannexb-flags -global header-segment format mpegtssegment2.ts18

DASH playlist and segmentSegmentboundaries N {0.000000,17.000000,24.000000,30.000000,43.000000, }video.mp4.mpd MPD type "static" xmlns "urn:mpeg:DASH:schema:MPD:2011”profiles ufferTime "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"/ . /SegmentTimeline /SegmentTemplate /Representation /AdaptationSet Template.19

Track split and repackage (MP4Box) Most DASH players don’t like video and audio tracks combined in a singlesegment.ffmpeg -itsoffset 17-i segment2.mp4-vcodec copy –ansegment2.video.mp4Video onlyMP4M4VMP4Box -noprog –quiet-dash 10000-single-segment –rap-out video temp.mpd-segment-name segmentsegment2.m4vMP4ffmpeg -itsoffset 17-i segment2.mp4-vn -acodec copysegment2.audio.mp4Audio onlyMP4M4AMP4Box -noprog –quiet-dash 10000-single-segment –rap-out video temp.mpd-segment-name segmentsegment2.m4v20

SupportingHLS 7 andup21

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 formatHLS 3Playlist#EXTM3U#EXT-X-STREAM-INF:PROGRAM-ID 1,BANDWIDTH 10130832,CODEC "avc1.640033,mp4a.40.2",RESOLUTION 3840x2160vide.mp4 1.m3u8#EXT-X-MEDIA:TYPE CLOSED-CAPTIONS,GROUPID "cc1",LANGUAGE ”en",NAME ”English",AUTOSELECT YES,DEFAULT YES,INSTREAM-ID -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-ENDLISTHLS 7Master playlistHLS 7Media MENTS#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-ENDLIST23

SegmentsHLS 7HLS oVideoAudioVideoAudioAudioAudio24

How to support HLS 7 r20 using NGINX RTMPHLS 7Segments#EXTM3U#EXT-X-STREAM-INF:PROGRAM-ID 1,BANDWIDTH 10130832,CODEC "avc1.640033,mp4a.40.2",RESOLUTION 3840x2160vide.mp4 1.m3u8#EXT-X-MEDIA:TYPE CLOSED-CAPTIONS,GROUPID "cc1",LANGUAGE "xx",NAME "Undefined",AUTOSELECT YES,DEFAULT YES,INSTREAM-ID "CC1"HLS 7Master MENTS#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-ENDLISTCreate byrulesVideoVideoAudioAudioConvert fromDASH mpdHLS 7Media playlistReuse DASHsegmentsVideoAudio25

Encrypting HLS26

Protecting HLS – How does it work?PlaylistIf a key isspecified KeySegmentDecrypt usingthe key27

Protecting HLS – How to make it work?#EXTM3U#EXT-X-VERSION:7#EXT-X-KEY:METHOD AES-128,URI ”video.key",IV 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-bitratestreaming(4K/8K UHD)by NGINX29

4K/8K UHD – How big are they?When horizontal and vertical resolutions are doubled, the amount ofdata are quadrupled. As a result, the number of pixels are growingexponentially 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 alityBitrate 31

Optimization for smooth 4K/8K experience Segment durationKey frame intervalMulti-bitrateNetwork optimizationHEVC/H.2652-4 seconds is recommended.Longer segments require longerinitial start up (e.g. 10 secondsegmentfrom12Mbps video dsegment isprocessUHD2todata.to edge/cache3MB)(Roughly)half-sizedserversdata for theclosetotheclient.same quality, or (also roughly)twice quality from the samebitrate.32

Low-latencylivestreaming byNGINX33

Low latency live – Why is it a such big challenge?HTTP-based streaming was originally not designed for live streaming.Encoder bufferIngest/playlistlatencyDelivery latencyPlayer bufferTotal 45-60seconds?34

Optimization for sub-10 seconds latency Smaller segment duration (2-3 seconds)Shorter key frame intervalSmaller playlist window (3x segment)Network optimizationThe smaller, the better, butChunk Transfer Encodingshould not be too small. (TooSegments start beingsent before they arecomplete.small segments make thePlayer bufferis beyondplayerto fail to make up aftercontrol. Wecanenforcea short network disturbance.)it to be small, by a smallplaylist window.35

Thank you.336

ffmpeg –ss 0 –itsoffset 0 –i video.mp4 –t 17 –codec copy segment1.mp4 ffmpeg –ss 17 –itsoffset 17 –i video.mp4 –t 24 –codec copy segment2.mp4 ffmpeg –ss 24 –itsoffset 24 –i video.mp4 –t 30 –codec copy segment3.mp4 Key

Related Documents:

85% savings over a replacement hardware load balancer such as F5 BIG-IP or Citrix NetScaler. Open source - NGINX Plus is based on NGINX open source, which is backed by an enthusiastic community of over 450 million users. There are thousands of community-contributed articles to help you on your journey. Learn more at nginx.com

Configuring DNS, Exchange, and Firewalls on page 6 Configuring NGINX Plus for Exchange on page 12 When configuring NGINX Plus, you choose between a basic deployment of load-balanced Exchange servers or a deployment with enhanced reliability, application health checks, and live activity monitoring. For details, see "Configuring NGINX

Bruksanvisning för bilstereo . Bruksanvisning for bilstereo . Instrukcja obsługi samochodowego odtwarzacza stereo . Operating Instructions for Car Stereo . 610-104 . SV . Bruksanvisning i original

10 tips och tricks för att lyckas med ert sap-projekt 20 SAPSANYTT 2/2015 De flesta projektledare känner säkert till Cobb’s paradox. Martin Cobb verkade som CIO för sekretariatet för Treasury Board of Canada 1995 då han ställde frågan

service i Norge och Finland drivs inom ramen för ett enskilt företag (NRK. 1 och Yleisradio), fin ns det i Sverige tre: Ett för tv (Sveriges Television , SVT ), ett för radio (Sveriges Radio , SR ) och ett för utbildnings program (Sveriges Utbildningsradio, UR, vilket till följd av sin begränsade storlek inte återfinns bland de 25 största

Hotell För hotell anges de tre klasserna A/B, C och D. Det betyder att den "normala" standarden C är acceptabel men att motiven för en högre standard är starka. Ljudklass C motsvarar de tidigare normkraven för hotell, ljudklass A/B motsvarar kraven för moderna hotell med hög standard och ljudklass D kan användas vid

LÄS NOGGRANT FÖLJANDE VILLKOR FÖR APPLE DEVELOPER PROGRAM LICENCE . Apple Developer Program License Agreement Syfte Du vill använda Apple-mjukvara (enligt definitionen nedan) för att utveckla en eller flera Applikationer (enligt definitionen nedan) för Apple-märkta produkter. . Applikationer som utvecklas för iOS-produkter, Apple .

PROVEEDOR DESCRIPCIÓN REFERENCIA MARCA SERVICIOS COMISIÓN DOMICILIADO O EP REGISTRADO SRI FECHA DE REGISTRO FECHA FIN DE REGISTRO PARAMOUNT 29 Contenidos audiovisuales por streaming 1 PARAMOUNT 16 Contenidos audiovisuales por streaming 1 PARAMOUNT 29 Contenidos audiovisuales por streaming 1 *HBO Contenidos audiovisuales por streaming 1 HBO ESPANA Contenidos audiovisuales por streaming 1