Hi.
I have set up a livestreaming platform with two Windows 7 machines but getting an issue. Client (videojs with HLS) stutters after about 14/15 minutes of streaming. I don't really know what can it be...what are your thoughs?
Below you'll find my config (and maybe is useful for someone else).
Machine 1: Encoder, with OBS
Custom Streaming to Machine 2 via RTMP to rtmp://<ip>:1935/transcode/test
Output: x264, CBR @ 6000kbps, Keyframe 3, veryfast, profile main, tune zerolatency, audio @ 160kpbs.
1280x720@30fps
Machine 2: Distributor via NGINX w/RTMP (v1.13.12) with transcoding for HLS.
FFMPEG runs as a batch process (no exec in Windows).
NGINX config:
VideoJS embedding HTML.
I have set up a livestreaming platform with two Windows 7 machines but getting an issue. Client (videojs with HLS) stutters after about 14/15 minutes of streaming. I don't really know what can it be...what are your thoughs?
Below you'll find my config (and maybe is useful for someone else).
Machine 1: Encoder, with OBS
Custom Streaming to Machine 2 via RTMP to rtmp://<ip>:1935/transcode/test
Output: x264, CBR @ 6000kbps, Keyframe 3, veryfast, profile main, tune zerolatency, audio @ 160kpbs.
1280x720@30fps
Machine 2: Distributor via NGINX w/RTMP (v1.13.12) with transcoding for HLS.
FFMPEG runs as a batch process (no exec in Windows).
Code:
ffmpeg.exe -i rtmp://localhost/transcode/test -async 1 -vsync -1 -c:v libx264 -x264opts keyint=90 -c:a aac -b:v 256k -b:a 32k -vf "scale=480:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/live/test_low -c:v libx264 -x264opts keyint=90 -c:a aac -b:v 768k -b:a 96k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/live/test_mid -c:v libx264 -x264opts keyint=90 -c:a aac -b:v 1024k -b:a 128k -vf "scale=960:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/live/test_high -c:v libx264 -x264opts keyint=90 -c:a aac -b:v 1920k -b:a 128k -vf "scale=1280:trunc(ow/a/2)*2" -tune zerolatency -preset veryfast -crf 23 -f flv rtmp://localhost/live/test_hd720 -c copy -f flv rtmp://localhost/live/test_src
NGINX config:
Code:
# *******************************************************************
# important notes for OBS studio on RTMP
# OBSstudio url
# rtmp://localhost:1935/live
# OBSstudio StreamKey
# test
# HTTP access
# http://localhost:8080/live/test/index.m3u8
# http://localhost:8080/ Welcome Nginx
# *******************************************************************
# Folders
# C:\nginx\nginx.exe
# C:\nginx\hls\live
# C:\nginx\hls\mobile
# C:\nginx\dash
# C:\nginx\html
# C:\nginx\conf
# C:\nginx\temp
# C:\nginx\logs
# C:\nginx\stats
# C:\nginx\videos
# *******************************************************************
worker_processes 1;
error_log logs/error.log debug;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
chunk_size 4000;
allow play all;
#creates our "live" full-resolution HLS videostream from our incoming encoder stream and tells where to put the HLS video manifest and video fragments
application transcode {
live on;
}
application live {
allow play all;
live on;
record off;
record_path /videos;
record_unique on;
hls on;
hls_nested on;
hls_path D:/nginx/HLS/live;
#hls_fragment 8s;
hls_fragment 6s;
hls_playlist_length 60s;
hls_fragment_naming timestamp;
hls_variant _low BANDWIDTH=288000; # Low bitrate, sub-SD resolution
hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
hls_variant _hd720 BANDWIDTH=2048000; # High bitrate, HD 720p resolution
# hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile off;
tcp_nopush on;
# aio on;
directio 512;
server {
listen 80;
server_name home;
#creates the http-location for our full-resolution (desktop) HLS stream - "http://localhost:8080/live/test/index.m3u8"
location /live {
types {
application/vnd.apple.mpegurl m3u8;
}
alias HLS/live;
add_header Cache-Control no-cache;
}
#allows us to see how stats on viewers on our Nginx site using a URL like: "http://my-ip/stats"
location /stats {
stub_status;
}
#allows us to host some webpages which can show our videos: "http://localhost:8080/index.html"
location / {
root D:/nginx/html;
index index.html index.htm;
}
}
}
VideoJS embedding HTML.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Video.js | HTML5 Video Player</title>
<link href="http://vjs.zencdn.net/7.0/video-js.min.css" rel="stylesheet">
<script src="videojs/video.min.js"></script>
</head>
<body>
<video id="video" preload="auto" class="video-js vjs-default-skin" controls >
<!-- <source src="http://cdd2180/live/test.m3u8" type="application/vnd.apple.mpegurl"> -->
</video>
<script src="videojs/hls.js"></script>
<script src="videojs/video.min.js"></script>
<!-- <script>
var player = videojs('video', {
// hlsjs tech should come before html5, if you want to give precedence to native HLS playback
// use the favorNativeHLS option.
techOrder: ["hlsjs", "html5"]
});
player.play();
</script> -->
<script>
var video = document.getElementById('video');
if(Hls.isSupported()) {
var hls = new Hls();
hls.loadSource('http://cdd2180/live/test.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.play();
});
}
// hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
// When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element throught the `src` property.
// This is using the built-in support of the plain video element, without using hls.js.
// Note: it would be more normal to wait on the 'canplay' event below however on Safari (where you are most likely to find built-in HLS support) the video.src URL must be on the user-driven
// white-list before a 'canplay' event will be emitted; the last video event that can be reliably listened-for when the URL is not on the white-list is 'loadedmetadata'.
else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = 'http://cdd2180/live/test.m3u8';
video.addEventListener('loadedmetadata',function() {
video.play();
});
}
</script>
</body>
</html>