因此,我有一个免费域并进行了设置,因此指向我的外部IP的记录点已在路由器上转发了端口80、1935和8080。 OBS可以正确地流到域,并且可以在VLC上看到该流,但是不能在我的博客作者(在LAN上)看到该流,也不能公开。我还修改了Windows主机文件,将域名和本地IP(我的PC)放入
我只能使用VLC观看流,这是使用以下“公式”-> rtmp // mydomain.xx / app / streamkey
虽然我可以在vlc中看到它,但在其他任何地方都无法使用。这是我的nginx.conf文件
#user nobody;
# multiple workers works !
worker_processes auto;
#pid logs/nginx.pid;
events {
worker_connections 8192;
}
rtmp {
server {
listen 1935;
allow play all;
chunk_size 4000;
application live {
live on;
allow publish all;
allow play all;
#enable HLS
hls on;
hls_path "my path";
hls_fragment 3;
hls_playlist_length 60;
}
}
}
http {
# Disable server tokens
server_tokens off;
# Include MIME types
include mime.types;
# Set timeout limit
keepalive_timeout 65;
server {
listen 80; # HTTP IPv4
listen [::]:80; # HTTP IPv6
server_name mydomain.xx www.mydomain.xx; # Your domain (RECOMMENDED BUT OPTIONAL)
location / {
# Disable cache
add_header Cache-Control no-cache;
# Enable CORS
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;
}
# Specify file type to be served (.m3u8)
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t;
}
# File location
# Set to the same hls_path specified in the rtmp application
root "my path";
}
}
}
这是用于测试它的index.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Player - Live 🔴</title>
<link href="https://vjs.zencdn.net/7.5.4/video-js.css" rel="stylesheet">
<script src='https://vjs.zencdn.net/7.5.4/video.js'></script>
</head>
<body>
<video id="player" class="video-js vjs-default-skin" width="800" height="440" controls preload="none">
<source src="http://mydomain.xx/app/streamkey.m3u8" type="application/x-mpegURL" />
</video>
<script>
var player = videojs('#player')
</script>
</body>
</html>
播放器无限加载,但从不显示单个帧...我很确定我在这里丢失了一些东西,但我可能错了(只是一个新手,哈哈)