This commit is contained in:
sxlxc
2025-07-19 12:22:11 +08:00
parent 3d1e96d5ce
commit 5056f68f08
3 changed files with 56 additions and 23 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
temp
logs

View File

@@ -16,17 +16,23 @@ events {
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
hls on;
hls_path temp/hls;
hls_fragment 1s;
hls_playlist_length 10s;
}
application hls {
live on;
hls on;
hls_path temp/hls;
hls_fragment 8s;
}
# application hls {
# live on;
# hls on;
# hls_path temp/hls;
# hls_fragment 8s;
# }
}
}
@@ -94,6 +100,25 @@ http {
#}
}
# hls
server {
listen 8080; # A non-standard port is good for local services.
location /hls {
# Serve HLS files
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
# The path here MUST match the hls_path from the rtmp block
alias temp/hls;
# Add headers to prevent caching and allow cross-domain playback
add_header Cache-Control 'no-cache';
add_header Access-Control-Allow-Origin '*' always;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#

View File

@@ -1,25 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
<title>HLS Player Test</title>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<h1>Live Stream</h1>
<video id="video" width="80%" controls></video>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<script>
var video = document.getElementById('video');
// ** CHANGE THIS URL TO YOUR STREAM URL **
var videoSrc = 'https://hls.talldoor.uk/hls/sxlxc.m3u8';
<p><em>Thank you for using nginx.</em></p>
if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(videoSrc);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = videoSrc;
video.addEventListener('loadedmetadata', function() {
video.play();
});
}
</script>
</body>
</html>
</html>