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.

17a8a63d6d97b2fb736285f0aff5b48f?s=128

NGINX Inc

May 13, 2014
Tweet

Transcript

  1. Video Streaming with NGINX Introduced by Andrew Alexeev Presented by

    Rick Nelson Nginx, Inc.
  2. 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.
  3. Video Streaming Methods File     Download   Progressive  

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

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

      to  disk   •  Playback  starts  aCer  the  download  completes   •  Download  stored  on  disk    
  6. 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  
  7. 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    
  8. 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  
  9. 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)    
  10. 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  
  11. 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  
  12. 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  
  13. INTRODUCING NGINX…

  14. 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
  15. 146,000,000 Websites NGINX Accelerates

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

  17. NGINX and NGINX Plus NGINX  F/OSS     nginx.org  

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

      –  NGINX  Plus  Lua   –  NGINX  Plus  Extras   –  NGINX  Plus  Streaming  Media  Server      
  20. VIDEO STREAMING WITH NGINX PLUS

  21. 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; }
  22. Demo: NGINX HLS

  23. 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; }
  24. Demo: NGINX HDS

  25. 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; }
  26. Demo: NGINX Pseudo-Streaming

  27. 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  
  28. 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; }
  29. 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  
  30. 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; } }
  31. Demo: NGINX Log Aggregation

  32. Demo: Show configuration file

  33. 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  
  34. Questions and Answers

  35. 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)