Reputation: 11
I'm trying to setup a livestreaming website and I'm encountering problems when trying to host node media server on my Ubuntu 20.04 VPS. Basically whenever the user starts the livestream it works when a viewer immediately connects to it but after it creates the index04.ts file in the media folder it just stops working completely with this error:
video append of 1308809b failed for segment #7 in playlist 0-https://example.com/live/testing/index.m3u8
(I intentionally made it example.com for this only, It's normally my actual domain.)
And it console logs this
VIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) video append of 1308809b failed for segment #7 in playlist 0-https://example.com/live/testing/index.m3u8 bt
(anonymous) @ video.min.js:12
video.min.js:12 VIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) audio append of 3448b failed for segment #7 in playlist 0-https://example.com/live/testing/index.m3u8 bt
(anonymous) @ video.min.js:12
video.min.js:12 VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The media could not be loaded, either because the server or network failed or because the format is not supported
Could anyone help me with this please? Everything works completely fine on a localhost environment which is why I'm incredibly confused.
My Code, server.js:
const NodeMediaServer = require('node-media-server');
const httpConfig = {
port: 80,
allow_origin: '*',
mediaroot: './media',
};
const rtmpConfig = {
port: 1935,
chunk_size: 128000,
gop_cache: true,
ping: 10,
ping_timeout: 60,
};
const transformationConfig = {
ffmpeg: '/usr/bin/ffmpeg',
tasks: [
{
app: 'live',
hls: true,
hlsFlags: '[hls_time=4:hls_list_size=10:hls_flags=delete_segments]',
hlsKeep: false,
hlsPath: './media',
},
],
MediaRoot: './media',
};
const config = {
http: httpConfig,
rtmp: rtmpConfig,
trans: transformationConfig,
};
const nms = new NodeMediaServer(config);
nms.on('prePublish', (id, StreamPath, args) => {
if (process.env.NODE_ENV !== 'production') {
console.log('prePublish:', id, StreamPath, args);
}
});
nms.on('postPublish', (id, StreamPath, args) => {
if (process.env.NODE_ENV !== 'production') {
console.log('postPublish:', id, StreamPath, args);
}
});
nms.on('donePublish', (id, StreamPath, args) => {
if (process.env.NODE_ENV !== 'production') {
console.log('donePublish:', id, StreamPath, args);
}
});
nms.on('prePlay', (id, StreamPath, args) => {
if (process.env.NODE_ENV !== 'production') {
console.log('prePlay:', id, StreamPath, args);
}
});
nms.on('postPlay', (id, StreamPath, args) => {
if (process.env.NODE_ENV !== 'production') {
console.log('postPlay:', id, StreamPath, args);
}
});
nms.on('donePlay', (id, StreamPath, args) => {
if (process.env.NODE_ENV !== 'production') {
console.log('donePlay:', id, StreamPath, args);
}
});
process.on('uncaughtException', (err) => {
console.error('Uncaught Exception:', err);
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
});
nms.run();
index.html:
<head>
<link href="https://vjs.zencdn.net/7.20.2/video-js.css" rel="stylesheet">
</head>
<body>
<h1>Live Stream</h1>
<video id="videoPlayer" class="video-js vjs-default-skin" controls autoplay width="640" height="360">
<source src="https://example.com/live/testing/index.m3u8" type="application/x-mpegURL">
</video>
<script>
document.addEventListener("DOMContentLoaded", () => {
var player = videojs('videoPlayer', {
techOrder: ['html5', 'flash'],
sources: [{
src: 'https://example.com/live/testing/index.m3u8',
type: 'application/x-mpegURL'
}]
});
});
</script>
I have tried to reset the VPS, Tried opening the ports using sudo ufw allow
. There's no guides online on how to fix this.
(My VPS has 4vCPU Cores, 6GB RAM & 400GB SSD so I have doubts that system requirements are the problem)
Upvotes: 0
Views: 194