SlideShare a Scribd company logo
1 of 35
Video Streaming with NGINX 
Introduced by Andrew Alexeev 
Presented by Rick Nelson 
Nginx Inc 
May 13, 2014
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.
Video Streaming Methods 
File 
Download 
Progressive 
Download 
Pseudo- 
Streaming 
Adaptive Bitrate 
Streaming 
RTMP
The Evolution of HTTP Video Streaming 
Pseudo- 
Streaming 
Adaptive Bitrate 
Streaming 
File 
Download 
Progressive 
Download
File Download 
N 
Internet 
Video Server 
Content 
downloaded 
to disk 
• Playback starts after the download completes 
• Download stored on disk
Progressive Download 
N 
Video Server 
META 
Progressive Download 
Content is streamed and played as it is downloaded 
• 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 
• Problematic with low bandwidth connections
Pseudo-Streaming 
Video Server 
META x 
Pseudo-streaming 
x 
Client can abort stream and request new byte-range 
N 
• Adds trick-play to progressive download 
• Client can request partial content 
• Content can be buffered by player
Adaptive Bitrate Streaming 
Video Server 
MANIFEST 
Adaptive Streaming 
Client downloads manifest, then video chunks of appropriate bitrate 
N 
• Data is sent as a continuous stream of small chunks 
• Supports trick-play capabilities 
• Supports variable bitrates supported 
• Easily change bitrates while streaming 
• Less buffering on the client 
• Better restoration from network interruptions
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)
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
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
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 software
INTRODUCING NGINX…
What is NGINX? 
Internet 
Proxy 
Caching, Load Balancing… HTTP traffic 
N 
Web Server 
Serve content from disk 
Application Server 
FastCGI, uWSGI, Passenger… 
Advanced Features: Bandwidth Management 
Application Acceleration 
SSL and SPDY termination 
Performance Monitoring 
High Availability 
Content-based Routing 
Request Manipulation 
Response Rewriting 
Authentication 
Mail Proxy 
Geo Location 
HLS 
HDS 
RTMP 
MP4/FLV 
MP4 Bandwidth
NGINX Accelerates 
146,000,000 
Websites
23% 
Top 1 million websites 38% 
Top 1,000 websites
NGINX and NGINX Plus 
NGINX F/OSS 
nginx.org 
3rd party 
modules 
Large community of >100 modules
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
NGINX Plus 
• NGINX Plus builds: 
– NGINX Plus 
– NGINX Plus Lua 
– NGINX Plus Extras 
– NGINX Plus Streaming Media Server
VIDEO STREAMING WITH NGINX PLUS
NGINX Plus and HTTP Live Streaming (HLS) 
• ngx_http_hls_module 
• NGINX creates playlist and segment files on-the-fly 
• Allows for existing mp4 files to be served by HLS 
• No need to re-package content 
• Save time and storage space 
location /hls { 
hls; 
}
Demo: NGINX HLS
NGINX Plus and HTTP Dynamic Streaming (HDS) 
• ngx_http_f4f_module 
• Manifest, index and segment files created by Adobe tools 
such as f4fpackager 
location /hds { 
f4f; 
}
Demo: NGINX HDS
NGINX and HTTP Pseudo-Streaming 
• ngx_http_mp4_module 
• Bandwidth can be controlled (NGINX Plus) 
location /video { 
mp4; 
mp4_limit_rate 1.2; 
mp4_limit_rate_after 15s; 
}
Demo: NGINX Pseudo-Streaming
NGINX Plus and RTMP Streaming 
• nginx-rtmp-module 
• RTMP live and VOD streaming 
• Stream transcoding with external software (ffmpeg, avconv) 
• HTTP callbacks on streaming events 
• Stream relay: push and pull
All (or some) Of The Above 
• Many types of clients 
• Many formats (Flash=HDS/RTMP, iPhone=HLS, etc.) 
• You will want to support multiple delivery methods 
root /tmp/mp4; 
location ~ .mp4$ { 
mp4; 
} 
location ~ .mp4.(m3u8|ts)$ { 
hls; 
}
Session Log Aggregation 
• ngx_http_session_log_module 
• Normal logging: One entry per segment 
request 
– High disk space usage 
– Excessive disk operations 
– Difficult to use for billing 
• Aggregation: Aggregates multiple requests
Session Log Aggregation 
Example: Log sessions based on client IP and user 
agent. Sessions expires after 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; 
} 
}
Demo: NGINX Log Aggregation
Demo: Show configuration file
Review 
• There are multiple ways to deliver video 
– HLS, HDS, pseudo-streaming, progressive download, RTMP 
• You will probably need to support multiple methods 
• NGINX Plus makes it easy
Questions and Answers
Closing thoughts 
• 38% of the busiest websites use NGINX 
• Check out the video streaming articles on nginx.com 
• Future webinars: nginx.com/webinars 
Try NGINX F/OSS (nginx.org) or NGINX Plus (nginx.com)

More Related Content

More from NGINX, Inc.

【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法NGINX, Inc.
 
Get Hands-On with NGINX and QUIC+HTTP/3
Get Hands-On with NGINX and QUIC+HTTP/3Get Hands-On with NGINX and QUIC+HTTP/3
Get Hands-On with NGINX and QUIC+HTTP/3NGINX, Inc.
 
Managing Kubernetes Cost and Performance with NGINX & Kubecost
Managing Kubernetes Cost and Performance with NGINX & KubecostManaging Kubernetes Cost and Performance with NGINX & Kubecost
Managing Kubernetes Cost and Performance with NGINX & KubecostNGINX, Inc.
 
Manage Microservices Chaos and Complexity with Observability
Manage Microservices Chaos and Complexity with ObservabilityManage Microservices Chaos and Complexity with Observability
Manage Microservices Chaos and Complexity with ObservabilityNGINX, Inc.
 
Accelerate Microservices Deployments with Automation
Accelerate Microservices Deployments with AutomationAccelerate Microservices Deployments with Automation
Accelerate Microservices Deployments with AutomationNGINX, Inc.
 
Unit 2: Microservices Secrets Management 101
Unit 2: Microservices Secrets Management 101Unit 2: Microservices Secrets Management 101
Unit 2: Microservices Secrets Management 101NGINX, Inc.
 
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
Unit 1: Apply the Twelve-Factor App to Microservices ArchitecturesUnit 1: Apply the Twelve-Factor App to Microservices Architectures
Unit 1: Apply the Twelve-Factor App to Microservices ArchitecturesNGINX, Inc.
 
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!NGINX, Inc.
 
Easily View, Manage, and Scale Your App Security with F5 NGINX
Easily View, Manage, and Scale Your App Security with F5 NGINXEasily View, Manage, and Scale Your App Security with F5 NGINX
Easily View, Manage, and Scale Your App Security with F5 NGINXNGINX, Inc.
 
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!NGINX, Inc.
 
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINXKeep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINXNGINX, Inc.
 
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...NGINX, Inc.
 
Protecting Apps from Hacks in Kubernetes with NGINX
Protecting Apps from Hacks in Kubernetes with NGINXProtecting Apps from Hacks in Kubernetes with NGINX
Protecting Apps from Hacks in Kubernetes with NGINXNGINX, Inc.
 
NGINX Kubernetes API
NGINX Kubernetes APINGINX Kubernetes API
NGINX Kubernetes APINGINX, Inc.
 
Successfully Implement Your API Strategy with NGINX
Successfully Implement Your API Strategy with NGINXSuccessfully Implement Your API Strategy with NGINX
Successfully Implement Your API Strategy with NGINXNGINX, Inc.
 
Installing and Configuring NGINX Open Source
Installing and Configuring NGINX Open SourceInstalling and Configuring NGINX Open Source
Installing and Configuring NGINX Open SourceNGINX, Inc.
 
Shift Left for More Secure Apps with F5 NGINX
Shift Left for More Secure Apps with F5 NGINXShift Left for More Secure Apps with F5 NGINX
Shift Left for More Secure Apps with F5 NGINXNGINX, Inc.
 
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptxHow to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptxNGINX, Inc.
 
Kubernetes環境で実現するWebアプリケーションセキュリティ
Kubernetes環境で実現するWebアプリケーションセキュリティKubernetes環境で実現するWebアプリケーションセキュリティ
Kubernetes環境で実現するWebアプリケーションセキュリティNGINX, Inc.
 
Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...
Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...
Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...NGINX, Inc.
 

More from NGINX, Inc. (20)

【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
【NGINXセミナー】API ゲートウェイとしてのNGINX Plus活用方法
 
Get Hands-On with NGINX and QUIC+HTTP/3
Get Hands-On with NGINX and QUIC+HTTP/3Get Hands-On with NGINX and QUIC+HTTP/3
Get Hands-On with NGINX and QUIC+HTTP/3
 
Managing Kubernetes Cost and Performance with NGINX & Kubecost
Managing Kubernetes Cost and Performance with NGINX & KubecostManaging Kubernetes Cost and Performance with NGINX & Kubecost
Managing Kubernetes Cost and Performance with NGINX & Kubecost
 
Manage Microservices Chaos and Complexity with Observability
Manage Microservices Chaos and Complexity with ObservabilityManage Microservices Chaos and Complexity with Observability
Manage Microservices Chaos and Complexity with Observability
 
Accelerate Microservices Deployments with Automation
Accelerate Microservices Deployments with AutomationAccelerate Microservices Deployments with Automation
Accelerate Microservices Deployments with Automation
 
Unit 2: Microservices Secrets Management 101
Unit 2: Microservices Secrets Management 101Unit 2: Microservices Secrets Management 101
Unit 2: Microservices Secrets Management 101
 
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
Unit 1: Apply the Twelve-Factor App to Microservices ArchitecturesUnit 1: Apply the Twelve-Factor App to Microservices Architectures
Unit 1: Apply the Twelve-Factor App to Microservices Architectures
 
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
NGINX基本セミナー(セキュリティ編)~NGINXでセキュアなプラットフォームを実現する方法!
 
Easily View, Manage, and Scale Your App Security with F5 NGINX
Easily View, Manage, and Scale Your App Security with F5 NGINXEasily View, Manage, and Scale Your App Security with F5 NGINX
Easily View, Manage, and Scale Your App Security with F5 NGINX
 
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
NGINXセミナー(基本編)~いまさら聞けないNGINXコンフィグなど基本がわかる!
 
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINXKeep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
Keep Ahead of Evolving Cyberattacks with OPSWAT and F5 NGINX
 
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
Install and Configure NGINX Unit, the Universal Application, Web, and Proxy S...
 
Protecting Apps from Hacks in Kubernetes with NGINX
Protecting Apps from Hacks in Kubernetes with NGINXProtecting Apps from Hacks in Kubernetes with NGINX
Protecting Apps from Hacks in Kubernetes with NGINX
 
NGINX Kubernetes API
NGINX Kubernetes APINGINX Kubernetes API
NGINX Kubernetes API
 
Successfully Implement Your API Strategy with NGINX
Successfully Implement Your API Strategy with NGINXSuccessfully Implement Your API Strategy with NGINX
Successfully Implement Your API Strategy with NGINX
 
Installing and Configuring NGINX Open Source
Installing and Configuring NGINX Open SourceInstalling and Configuring NGINX Open Source
Installing and Configuring NGINX Open Source
 
Shift Left for More Secure Apps with F5 NGINX
Shift Left for More Secure Apps with F5 NGINXShift Left for More Secure Apps with F5 NGINX
Shift Left for More Secure Apps with F5 NGINX
 
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptxHow to Avoid the Top 5 NGINX Configuration Mistakes.pptx
How to Avoid the Top 5 NGINX Configuration Mistakes.pptx
 
Kubernetes環境で実現するWebアプリケーションセキュリティ
Kubernetes環境で実現するWebアプリケーションセキュリティKubernetes環境で実現するWebアプリケーションセキュリティ
Kubernetes環境で実現するWebアプリケーションセキュリティ
 
Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...
Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...
Software Delivery and the Rube Goldberg Machine: What Is the Problem We Are T...
 

Recently uploaded

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Video Streaming with NGINX

  • 1. Video Streaming with NGINX Introduced by Andrew Alexeev Presented by Rick Nelson Nginx Inc May 13, 2014
  • 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 Adaptive Bitrate Streaming RTMP
  • 4. The Evolution of HTTP Video Streaming Pseudo- Streaming Adaptive Bitrate Streaming File Download Progressive Download
  • 5. File Download N Internet Video Server Content downloaded to disk • Playback starts after the download completes • Download stored on disk
  • 6. Progressive Download N Video Server META Progressive Download Content is streamed and played as it is downloaded • 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 • Problematic with low bandwidth connections
  • 7. Pseudo-Streaming Video Server META x Pseudo-streaming x Client can abort stream and request new byte-range N • Adds trick-play to progressive download • Client can request partial content • Content can be buffered by player
  • 8. Adaptive Bitrate Streaming Video Server MANIFEST Adaptive Streaming Client downloads manifest, then video chunks of appropriate bitrate N • Data is sent as a continuous stream of small chunks • Supports trick-play capabilities • Supports variable bitrates supported • Easily change bitrates while streaming • Less buffering on the client • Better restoration from network interruptions
  • 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 software
  • 14. What is NGINX? Internet Proxy Caching, Load Balancing… HTTP traffic N Web Server Serve content from disk Application Server FastCGI, uWSGI, Passenger… Advanced Features: Bandwidth Management Application Acceleration SSL and SPDY termination Performance Monitoring High Availability Content-based Routing Request Manipulation Response Rewriting Authentication Mail Proxy Geo Location HLS HDS RTMP MP4/FLV MP4 Bandwidth
  • 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_http_hls_module • NGINX creates playlist and segment files on-the-fly • Allows for existing mp4 files to be served by HLS • No need to re-package content • Save time and storage space location /hls { hls; }
  • 23. NGINX Plus and HTTP Dynamic Streaming (HDS) • ngx_http_f4f_module • Manifest, index and segment files created by Adobe tools such as f4fpackager location /hds { f4f; }
  • 25. NGINX and HTTP Pseudo-Streaming • ngx_http_mp4_module • Bandwidth can be controlled (NGINX Plus) location /video { mp4; mp4_limit_rate 1.2; mp4_limit_rate_after 15s; }
  • 27. NGINX Plus and RTMP Streaming • nginx-rtmp-module • RTMP live and VOD streaming • Stream transcoding with external software (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 multiple delivery methods root /tmp/mp4; location ~ .mp4$ { mp4; } location ~ .mp4.(m3u8|ts)$ { hls; }
  • 29. Session Log Aggregation • ngx_http_session_log_module • Normal logging: One entry per segment request – High disk space usage – Excessive disk operations – Difficult to use for billing • Aggregation: Aggregates multiple requests
  • 30. Session Log Aggregation Example: Log sessions based on client IP and user agent. Sessions expires after 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
  • 33. Review • There are multiple ways to deliver video – HLS, HDS, pseudo-streaming, progressive download, RTMP • You will probably need to support multiple methods • NGINX Plus makes it easy
  • 35. Closing thoughts • 38% of the busiest websites use NGINX • Check out the video streaming articles on nginx.com • Future webinars: nginx.com/webinars Try NGINX F/OSS (nginx.org) or NGINX Plus (nginx.com)

Editor's Notes

  1. Thank you Andrew. Over the years different methods have been devised to deliver video content. In this webinar we will take a look at some of these methods and then I will talk about how you can use NGINX for video delivery.
  2. Today the methods I will be talking about are file download, progressive download, pseudo-streaming, adaptive bitrate streaming and RTMP.
  3. I’m going to start by discussing how these methods have evolved over time, focusing on HTTP and so for that I will cover file download, progressive download, pseudo streaming and adaptive bitrate streaming.
  4. We will start with the simplest way of delivering video content and that is to download the complete media file to your local hard drive and then playing the video. The process is very straight forward. The file is downloaded from the video server to the local machine and once the download completes the video can be played. This means that you have to wait for the entire file to be downloaded before playback can begin and if the file is large or your link is slow this can take a very long time and if you are unlucky and run into connection errors, the download may never complete. So there is obviously room for improvement.
  5. An improvement over simply downloading a file is progressive download. In this scenario, the meta data for the media file (that is the information needed by the video player to know how to play the video) is downloaded first, then the download of the rest of the file begins and after a certain amount of data is buffered by the player it is able to start playing the video. The file will continue to download and as long as the file downloads faster then the video plays, you will experience smooth playback. If your link is slow, then the playback may stall while the player waits for more data to be buffered. I’m sure you have all encountered this phenomena. So this method does not handle slow connections well and you aren’t able to use trick play features such as fast forward, jumping to a certain part of the video, etc. The key advantage to this approach over file download is that you don’t have to wait for the download to complete before playing the video so the video can be played while the file is still being downloaded. This is made possible by moving the meta data to the front of the file so the player has the information it needs to play the file. So this a step in the right direction, but still is not ideal.
  6. Pseudo-streaming is an advance on simple progressive download in that the player can ask for specific byte ranges, thus enabling some trick play features and also the player can buffer the data without necessarily having to write the data to disk. The download no longer has to be continuous from the start to the end of the file. The player can now stop the stream and move to a new point in the data.
  7. A big step forward came with the advent of adaptive bitrate streaming. This delivers the media in a different way then the progressive download and pseudo-streaming methods we have been talking about. Here a media file is repackaged as a series of smaller segments, each with just a few seconds of video. A playlist or manifest file is then created that acts as a table of contents for the segments. What adaptive bitrate refers to is that there can be different versions of the same video, each encoded with a different bitrate. Think of a having a high definition and low definition version of the same video and even versions in between. The high definition version would be appropriate for a high bandwidth link and the low definition version appropriate for a low bandwidth link. With adaptive bitrate streaming the player can switch seamlessly between bitrates depending on the speed of the connection and can easily skip forward or backward through the segment files. By being able to adapt to network conditions using different bitrates the client can see a better quality of service, and the player can also more easily recover from network interruptions.
  8. Now let’s look at two popular ways of doing adaptive bitrate streaming over HTTP and how they work. HTTP Live Streaming, or HLS, was developed by Apple. With HLS, the mp4 file is re-packaged into a playlist with the extension of m3u8 and a series of short segment files with an extension of ts. The playlist is used to identify the segments. A player first requests the playlist and then streams the segment files. HTTP Dynamic Streaming, or HDS, comes from Adobe and also requires that the content to be re-packaged, but in this case into a manifest file, an index file and a fragment file. If you have encoded the video with multiple bitrates, then you will have a master playlist or manifest file that points to a playlist or manifest file for each bitrate.
  9. Hopefully this diagram will clarify things. This shows the file structure used by HLS, assuming there are 2 bitrates available. The master playlist points to a playlist for each bitrate and these playlists point to the segment files. I only show the first 2 segment files. The number of segment files will depend on the length of the segments and the total length of the video. If you only have a single bitrate, then there would be no master playlist.
  10. Here we see the file structure for HDS. Again I have assumed 2 bitrates. So there is a master manifest that points to the manifest for each bitrate. These manifest then point to an index which points to the fragment file. Again if you have only a single bitrate there will not be a master manifest.
  11. Another way of doing video streaming that doesn’t use HTTP, is to use the Real Time Messaging Protocol or RTMP. This can support both live video and video on demand and is supported across various desktop browsers by means of a Flash plugin, and it is also supported by many other software programs.
  12. Now that we covered a bit about video streaming in general, let’s take a look at how you can use NGINX to support your video streaming requirements.
  13. First off, what is NGINX? NGINX is a high performance web server of static content, including video and also a full reverse proxy or Application Delivery Controller with many advanced features. For dynamic content it can connect to application servers over HTTP, FastCGI, uWSGI, Passenger and other methods.
  14. Started as on open source project about 10 years ago, NGINX has gained a justified reputation as a high performance web and proxy server and is seeing widespread adoption, now powering over 140 million websites.
  15. Including over 20% of the top 1 million busiest websites and almost 40% of the top 1,000 busiest websites, which now makes NGINX the most used web server for the top 1,000 websites.
  16. As I said, NGINX started out as an open source project and that continues today, but in August of last year we released the first commercial version of NGINX, NGINX Plus, built on top of the open source version.
  17. NGINX Plus brings advanced features, mainly around enterprise level load balancing and video streaming and also comes with support. As we go through this presentation, we will talk about some of the NGINX Plus features specific to video streaming.
  18. There are four builds of NGINX Plus that are available. NGINX Plus is the core build and all the code in this build has been developed by the Nginx team in Moscow, the same team that develops the open source version, and is fully supported. The NGINX Plus Lua build adds the popular 3rd party module that allows you to do scripting in the Lua programming language. The NGINX Plus Extras build adds several additional 3rd party modules. These 3rd party modules are supported on a best effort basis. And finally there is the NGINX Plus Streaming Media Server. This is a stripped down version of NGINX Plus, with just those features needed for video streaming.
  19. So now let’s talk about how you can use NGINX to do video streaming.
  20. We’ll start with HLS. NGINX Plus includes a HLS module. You may remember that when I talked about HLS previously I mentioned that the content needs to be re-packaged into a playlist and segment files. One of the nice features of the NGINX Plus HLS module is that it can do this re-packaging for you, on-the-fly. So you can take your existing mp4 files and start serving them with HLS without having to do anything to the files. Just point NGINX Plus at your mp4 files and NGINX Plus will do the rest. If you want to support multiple bitrates, then all you need to do is create a master playlist pointing to the playlist for each bitrate. These playlist files won’t actually exist, but NGINX will create them automatically at run time.
  21. Now I will start showing demos using NGINX to deliver video using some of the methods I have been talking about. First, let’s see HLS in action. You will see that if we look in the /mp4 directory, we just have the file catanddog.mp4, but if we go to our browser and enter catanddog.mp4.m3u8, which is the URI of the playlist, we see our video even though that file doesn’t exist. This is because NGINX created it on the fly. If we look in the access log, we will see the request for the m3u8 file along with the segment files, which were also created on-the-fly by NGINX. Show /mp4 Browser http://vidtest/mp4/catanddog.mp4.m4u8 Show /etc/nginx/logs/hls.access.log
  22. Now let’s move on to HDS. HDS is a different then HLS in that the mp4 encoded files must be re-packaged with an Adobe tool, like f4fpackager. Once this is done the f4f module that comes with NGINX Plus will handle the HDS streaming requests.
  23. If we look in the hds directory where I have put the HDS files, we will see the manifest, index and segment file. To use HDS we need to embed a flash player in a webpage, which is what we have done here and we see the same video we saw during the HLS demo. If we look at the access log for these requests we will see many request for cat1-Frag1, cat1-Frag2 and so on and the HDS module has the logic to know how to handle those requests. Show /hds Browser http://test-f4f.html Show /etc/nginx/logs/hds.access.log
  24. Now, adaptive bitrate streaming is great and I’ve talked about some of its advantages, but not all client devices may support it, so you may still want to support pseudo-streaming and that is something supported in NGINX open source, but NGINX Plus adds the ability to control the bandwidth used by a client over a connection. mp4_limit_rate is multiplied by the bitrate, so in this example we will allow 1.2 times the encoded bitrate for each connection. mp4_limit_rate_after tells NGINX Plus to delay starting to limit the bandwidth for the specified time after the download begins. So in this example, 15 seconds. This allows the client to buffer an initial amount of video before before the limit kicks in.
  25. As we saw when we looking in the /mp4 directory, we had just the one mp4 file. For the previous demo, we requested the playlist, but if request the file directly, then the video will be played using pseudo-streaming. Browser http://vidtest/mp4/catanddog.mp4
  26. One alternative to HTTP streaming I mentioned was RTMP and NGINX has a module for this too. Some of the notable features of this module are that, although it does not support transcoding (converting live stream to a different codec, size, bitrate, etc.), it does support external process execution using transcoders such as ffmpeg, avconv, etc. These processes usually connect to NGINX as a subscriber, receive the stream and publish it back transcoded under a different name. Also for certain streaming events (publisher connect/disconnect or subscriber connect/disconnect) the module can make HTTP subrequests.  This allows you to add business logic. For example to check a database entry and drop the RTMP connection if the check fails.  RTMP secure links use this feature as well. And when a client publishes the stream, the module can push the stream to another server.  Or when a subscriber tries to play a missing stream the module can pull the stream from a remote server.
  27. With the proliferation of devices, each with different functionality, you are probably going to have to support multiple delivery methods. For example, for Flash players you are going to need to support HDS and/or RTMP and for iPhones you will want to support HLS and since not all devices may support these delivery methods you will probably also want to still support psuedo-streaming. Here is an example configuration that will take the same mp4 file and serve it via pseudo-streaming if a client requests has an extension of mp4 since it is requesting the file directly and will serve it via HLS if the client request has an extension of mp4.m3u8 since the client is requesting an HLS playlist. You can also have a configuration that has NGINX serving HDS, RTMP, etc. For example, the configuration I am using also support HLS.
  28. As you saw when I did the demos, if you have access logging turned on, like I do, you will get an entry for each individual request during the streaming. That was good for my demos, to show you what was going on, but for a production system, with possibly thousands, tens of thousands or even more clients, you can image how many log entries would result. This can cause very high disk usage and excessive disk operations and also is too granular to use for billing if that is necessary. NGINX Plus introduces the ability to aggregate log entries based on criteria you specify so you get higher level log entries rather then one for each segment. This results in less disk storage, less disk I/O and data that is much more useful for billing.
  29. Here is an example configuration that does log aggregation for HDS, logging based on client IP and user agent and once a given client IP and user agent is inactive for 30 seconds the session will be considered complete and the log entry will be written.
  30. When I showed you the HLS demo previously, I showed you the detailed access log, but I also had log aggregation configured. Here again is the detailed log, and here is the aggregate log for the same session. Show /etc/nginx/logs/hls.access.log Show /etc/nginx/logs/hls.log
  31. Here is the full configuration file I used for all the demonstrations I’ve shown. Show /etc/nginx/conf.d/video.conf
  32. As we come to the end, let’s do a quick review. We talked about a number of ways that can be used to deliver video, including HLS, HDS, pseudo-streaming, progressive download and RTMP. And given the vast array of different mobile clients, desktop browsers and other clients, you will probably need to support many of these methods. NGINX Plus supports all of them, and does it in a way that is easy to configure.
  33. Now we will open the floor for questions.
  34. Thank you for taking the time to attend this session. I hope it was of use to you and I hope you attend some of our future webinars. You will find additional information about video streaming at nginx.com. And it is easy to test out either the open source version of NGINX or NGINX Plus.