使用 NGINX 的 WebRTC
我想在 Web 应用程序中显示 RTSP 流。我使用 HLS 成功进行了流式传输,配置如下: RTSP 到 RTMP:
ffmpeg -stream_loop -1 -re -i "C:\RA\test.m3u8" -acodec aac -vcodec libx264 -f flv rtmp:localhost/live/stream
Nginx(Windows 上为 1.7)配置
# RTMP configuration
rtmp {
server {
listen 1935;
application live {
live on;
interleave on;
hls on;
hls_path C:\RA\NGINX\hls;
hls_fragment 15s;
}
}
}
http {
sendfile off;
tcp_nopush on;
directio 512;
default_type application/octet-stream;
server {
listen 81;
location / {
# Disable cache
add_header 'Cache-Control' 'no-cache';
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root C:\RA\NGINX;
}
}
}
我找不到与 NGINX 的 WebRTC 配置相关的文档或示例 我尝试使用套接字连接,但我不知道如何定义我的输入流,也不知道测试这个的 URL 是什么...
# RTMP configuration
rtmp {
server {
listen 1935;
application live {
live on;
}
}
}
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server localhost:8010;
}
server {
listen 8020;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}
}
}
I would like to show a RTSP stream in a Web application. I successfully streamed using HLS with the following configuration:
RTSP to RTMP:
ffmpeg -stream_loop -1 -re -i "C:\RA\test.m3u8" -acodec aac -vcodec libx264 -f flv rtmp:localhost/live/stream
Nginx (1.7 on windows) configuration
# RTMP configuration
rtmp {
server {
listen 1935;
application live {
live on;
interleave on;
hls on;
hls_path C:\RA\NGINX\hls;
hls_fragment 15s;
}
}
}
http {
sendfile off;
tcp_nopush on;
directio 512;
default_type application/octet-stream;
server {
listen 81;
location / {
# Disable cache
add_header 'Cache-Control' 'no-cache';
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
types {
application/dash+xml mpd;
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root C:\RA\NGINX;
}
}
}
I cannot find the documentation or examples related to the WebRTC configuration for NGINX
I tried with the socket connection but I don't know how to defined my input stream or what would be the URL to test this...
# RTMP configuration
rtmp {
server {
listen 1935;
application live {
live on;
}
}
}
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server localhost:8010;
}
server {
listen 8020;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论