Slide 1

Slide 1 text

Video Streaming with NGINX Introduced by Andrew Alexeev Presented by Rick Nelson Nginx, Inc.

Slide 2

Slide 2 text

About this webinar The demand for Internet Video continues to grow at a fast pace and from all types of devices. In this webinar, you'll learn about the different methods for streaming video and how some of the advanced features of NGINX and NGINX Plus can be used to meet your video streaming needs.

Slide 3

Slide 3 text

Video Streaming Methods File     Download   Progressive   Download   Pseudo-­‐ Streaming   Adap8ve  Bitrate   Streaming   RTMP    

Slide 4

Slide 4 text

The Evolution of HTTP Video Streaming Pseudo-­‐ Streaming   Adap8ve  Bitrate   Streaming   File     Download   Progressive   Download  

Slide 5

Slide 5 text

File Download N Internet Video  Server   Content   downloaded   to  disk   •  Playback  starts  aCer  the  download  completes   •  Download  stored  on  disk    

Slide 6

Slide 6 text

Progressive Download N Video  Server   Progressive  Download   Content  is  streamed  and  played  as  it  is  downloaded   META   •  Playback  starts  before  download  completes   •  Meta  data  at  the  beginning  of  the  file   •  Download  stored  on  disk   •  Trick-­‐play  and  media  flow  control  not  easy   •  Problema8c  with  low  bandwidth  connec8ons  

Slide 7

Slide 7 text

Pseudo-Streaming Video  Server   Pseudo-­‐streaming   Client  can  abort  stream  and  request  new  byte-­‐range   META   x   x   N •  Adds  trick-­‐play  to  progressive  download   •  Client  can  request  par8al  content   •  Content  can  be  buffered  by  player    

Slide 8

Slide 8 text

Adaptive Bitrate Streaming Video  Server   Adap9ve  Streaming   Client  downloads  manifest,  then  video  chunks  of  appropriate  bitrate     MANIFEST   N •  Data  is  sent  as  a  con8nuous  stream  of  small  chunks   •  Supports  trick-­‐play  capabili8es   •  Supports  variable  bitrates  supported   •  Easily  change  bitrates  while  streaming     •  Less  buffering  on  the  client   •  BeNer  restora8on  from  network  interrup8ons  

Slide 9

Slide 9 text

Adaptive Bitrate Streaming •  HTTP  Live  Streaming  (HLS)   –  From  Apple   –  Package  MP4  encoded  file  to:   •  Playlist  (.m3u8)   •  Segment  files  (.ts)   •  HTTP  Dynamic  Streaming  (HDS)   –  From  Adobe   –  Package  MP4  encoded  file  to:   •  Manifest  (.f4m)   •  Index  (.f4x)   •  Fragment(.f4f)    

Slide 10

Slide 10 text

HLS File Structure Master  Playlist   .mp4.m3u8   Playlist  Bitrate  1   .mp4.m3u8   Segment  1  Bitrate  1   .mp4.ts   Segment  2  Bitrate  1   .mp4.ts   Playlist  Bitrate  2   .mp4.m3u8   Segment  1  Bitrate  2   .mp4.ts   Segment  2  Bitrate  2   .mp4.ts  

Slide 11

Slide 11 text

HDS File Structure Master  Manifest   .f4m   Manifest  Bitrate  1   .f4m   Index      Bitrate  1   .f4x   Fragment  Bitrate  1   .f4f   Manifest  Bitrate  2   .f4m   Index      Bitrate  2   .f4x   Fragment  Bitrate  2   .f4f  

Slide 12

Slide 12 text

Real Time Messaging Protocol (RTMP) •  TCP-­‐based  streaming  protocol   •  Developed  by  MacroMedia  –  Now  Adobe   •  Live  and  VOD  streaming   •  Wide  desktop  browser  support  via  Flash  plugin   •  Supported  by  a  variety  of  soCware  

Slide 13

Slide 13 text

INTRODUCING NGINX…

Slide 14

Slide 14 text

What is NGINX? Internet N Web Server Serve content from disk Application Server FastCGI, uWSGI, Passenger… Proxy Caching, Load Balancing… HTTP traffic þ Application Acceleration þ SSL and SPDY termination þ Performance Monitoring þ High Availability Advanced Features: þ Bandwidth Management þ Content-based Routing þ Request Manipulation þ Response Rewriting þ Authentication þ Mail Proxy þ Geo Location þ HLS þ HDS þ RTMP þ MP4/FLV þ MP4 Bandwidth

Slide 15

Slide 15 text

146,000,000 Websites NGINX Accelerates

Slide 16

Slide 16 text

23% Top 1 million websites 38% Top 1,000 websites

Slide 17

Slide 17 text

NGINX and NGINX Plus NGINX  F/OSS     nginx.org   3rd  party     modules   Large  community  of  >100  modules  

Slide 18

Slide 18 text

NGINX and NGINX Plus NGINX  F/OSS     nginx.org   3rd  party     modules   Large  community  of  >100  modules   NGINX  Plus     Advanced  load  balancing  features   Ease-­‐of-­‐management   Commercial  support  

Slide 19

Slide 19 text

NGINX Plus •  NGINX  Plus  builds:   –  NGINX  Plus   –  NGINX  Plus  Lua   –  NGINX  Plus  Extras   –  NGINX  Plus  Streaming  Media  Server      

Slide 20

Slide 20 text

VIDEO STREAMING WITH NGINX PLUS

Slide 21

Slide 21 text

NGINX Plus and HTTP Live Streaming (HLS) •  ngx_hNp_hls_module   •  NGINX  creates  playlist  and  segment  files  on-­‐the-­‐fly   •  Allows  for  exis8ng  mp4  files  to  be  served  by  HLS   •  No  need  to  re-­‐package  content   •  Save  8me  and  storage  space     location /hls { hls; }

Slide 22

Slide 22 text

Demo: NGINX HLS

Slide 23

Slide 23 text

NGINX Plus and HTTP Dynamic Streaming (HDS) •  ngx_hNp_f4f_module   •  Manifest,  index  and  segment  files  created  by  Adobe  tools   such  as  f4fpackager   location /hds { f4f; }

Slide 24

Slide 24 text

Demo: NGINX HDS

Slide 25

Slide 25 text

NGINX and HTTP Pseudo-Streaming •  ngx_hNp_mp4_module   •  Bandwidth  can  be  controlled  (NGINX  Plus)   location /video { mp4; mp4_limit_rate 1.2; mp4_limit_rate_after 15s; }

Slide 26

Slide 26 text

Demo: NGINX Pseudo-Streaming

Slide 27

Slide 27 text

NGINX Plus and RTMP Streaming •  nginx-­‐rtmp-­‐module   •  RTMP  live  and  VOD  streaming   •  Stream  transcoding  with  external  soCware  (ffmpeg,  avconv)   •  HTTP  callbacks  on  streaming  events   •  Stream  relay:  push  and  pull  

Slide 28

Slide 28 text

All (or some) Of The Above •  Many  types  of  clients   •  Many  formats  (Flash=HDS/RTMP,  iPhone=HLS,  etc.)   •  You  will  want  to  support  mul8ple  delivery  methods   root /tmp/mp4; location ~ \.mp4$ { mp4; } location ~ \.mp4\.(m3u8|ts)$ { hls; }

Slide 29

Slide 29 text

Session Log Aggregation •  ngx_hNp_session_log_module   •  Normal  logging:  One  entry  per  segment   request   –  High  disk  space  usage   –  Excessive  disk  opera8ons     –  Difficult  to  use  for  billing   •  Aggrega8on:  Aggregates  mul8ple  requests  

Slide 30

Slide 30 text

Session Log Aggregation Example:  Log  sessions  based  on  client  IP  and  user   agent.    Sessions  expires  aCer  in  30  seconds.   session_log_zone /var/log/nginx/sessions.log format=combined zone=one:1m timeout=30s md5=$binary_remote_addr$http_user_agent; server { [..] location /hds/ { session_log one; f4f; } }

Slide 31

Slide 31 text

Demo: NGINX Log Aggregation

Slide 32

Slide 32 text

Demo: Show configuration file

Slide 33

Slide 33 text

Review •  There  are  mul8ple  ways  to  deliver  video   –  HLS,  HDS,  pseudo-­‐streaming,  progressive  download,  RTMP   •  You  will  probably  need  to  support  mul8ple  methods   •  NGINX  Plus  makes  it  easy  

Slide 34

Slide 34 text

Questions and Answers

Slide 35

Slide 35 text

Closing thoughts •  38%  of  the  busiest  websites  use  NGINX   •  Check  out  the  video  streaming  ar8cles  on  nginx.com   •  Future  webinars:  nginx.com/webinars   Try  NGINX  F/OSS  (nginx.org)  or  NGINX  Plus  (nginx.com)