Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Video streaming with NGINX

Video streaming with NGINX

For the recorded webinar, visit nginx.com/webinars.

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.

NGINX Inc

May 13, 2014
Tweet

More Decks by NGINX Inc

Other Decks in Technology

Transcript

  1. 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.
  2. Video Streaming Methods File     Download   Progressive  

    Download   Pseudo-­‐ Streaming   Adap8ve  Bitrate   Streaming   RTMP    
  3. The Evolution of HTTP Video Streaming Pseudo-­‐ Streaming   Adap8ve

     Bitrate   Streaming   File     Download   Progressive   Download  
  4. File Download N Internet Video  Server   Content   downloaded

      to  disk   •  Playback  starts  aCer  the  download  completes   •  Download  stored  on  disk    
  5. 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  
  6. 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    
  7. 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  
  8. 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)    
  9. 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  
  10. 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  
  11. 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  
  12. 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
  13. NGINX and NGINX Plus NGINX  F/OSS     nginx.org  

    3rd  party     modules   Large  community  of  >100  modules  
  14. 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  
  15. NGINX Plus •  NGINX  Plus  builds:   –  NGINX  Plus

      –  NGINX  Plus  Lua   –  NGINX  Plus  Extras   –  NGINX  Plus  Streaming  Media  Server      
  16. 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; }
  17. 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; }
  18. 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; }
  19. 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  
  20. 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; }
  21. 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  
  22. 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; } }
  23. 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  
  24. 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)