Add low_delay option + uses the ingest stream for publication

This commit is contained in:
Jan Stabenow 2022-09-29 18:26:06 +02:00
parent 2cb2881e3c
commit a59c766c4d
No known key found for this signature in database
GPG Key ID: 9C22DD65A9AAF133
9 changed files with 52 additions and 11 deletions

View File

@ -2,6 +2,8 @@
### v1.2.0 > v1.3.0
- Add low_delay option to processing (default: true)
- Mod uses the ingest stream for publication (datarhei/restreamer#411)
- Add dlive & Trovo publication services
- Mod optimized DVR on DiskFS
- Mod updates packages

View File

@ -15,6 +15,9 @@ export default function Player(props) {
liveui: true,
responsive: true,
fluid: true,
plugins: {
reloadSourceOnError: {}
},
sources: [{ src: props.source, type: 'application/x-mpegURL' }],
};

View File

@ -13,6 +13,7 @@ function init(settings) {
reconnect: true,
delay: 30,
staleTimeout: 30,
low_delay: true,
...settings,
};
@ -31,7 +32,7 @@ export default function Control(props) {
const handleChange = (what) => (event) => {
const value = event.target.value;
if (['autostart', 'reconnect', 'cleanup'].includes(what)) {
if (['autostart', 'reconnect', 'low_delay'].includes(what)) {
settings[what] = !settings[what];
} else {
settings[what] = value;
@ -44,6 +45,7 @@ export default function Control(props) {
<Grid container spacing={2}>
<Grid item xs={12}>
<Checkbox label={<Trans>Reconnect</Trans>} checked={settings.reconnect} onChange={handleChange('reconnect')} />
<Checkbox label={<Trans>Low delay</Trans>} checked={settings.low_delay} onChange={handleChange('low_delay')} />
</Grid>
<Grid item xs={12} md={6}>
<TextField

View File

@ -278,6 +278,7 @@ const defaultIngestMetadata = {
reconnect: true,
delay: 15,
staleTimeout: 30,
low_delay: true,
},
snapshot: {
enable: true,

View File

@ -1593,6 +1593,14 @@ class Restreamer {
if (control.rtmp && control.rtmp.enable && rtmp_config.enabled) {
rtmp_enabled = true;
}
if (
proc.input[0].address.includes('rtmp://localhost') &&
proc.input[0].address.includes(channel.channelid) &&
!proc.input[0].address.includes('ingest')
) {
rtmp_enabled = false;
control.rtmp.enable = true;
}
// 1.3 Fetch srt settings
const srt_config = core_config.source.network.srt;
@ -1600,6 +1608,14 @@ class Restreamer {
if (control.srt.enable && srt_config.enabled) {
srt_enabled = true;
}
if (
proc.input[0].address.includes('srt://localhost') &&
proc.input[0].address.includes(channel.channelid) &&
!proc.input[0].address.includes('ingest')
) {
srt_enabled = false;
control.srt.enable = true;
}
// 1.4 'tee_muxer' is required for the delivery of one output to multiple endpoints without processing the input for each output
// http://ffmpeg.org/ffmpeg-all.html#tee-1
@ -1747,7 +1763,14 @@ class Restreamer {
.map((o) => o[0] + '=' + o[1])
.join(':');
output.options.push('-flags', '+global_header', '-tag:v', '7', '-tag:a', '10', '-f', 'tee');
// set flags
if (control.process.low_delay) {
output.options.push('-flags', '+low_delay+global_header');
} else {
output.options.push('-flags', '+global_header');
}
output.options.push('-tag:v', '7', '-tag:a', '10', '-f', 'tee');
// ['f=hls:start_number=0...]address.m3u8
// use tee_muxer formatting
output.address =
@ -1759,6 +1782,11 @@ class Restreamer {
// adding the '-' in front of the first option, then flatten everything
const hls_params = hls_params_raw.map((o) => ['-' + o[0], o[1]]).reduce((acc, val) => acc.concat(val), []);
// set flags
if (control.process.low_delay) {
output.options.push('-flags', '+low_delay');
}
output.options.push(...hls_params);
}
@ -2552,10 +2580,18 @@ class Restreamer {
output.options = [];
}
// set flags
let options = [];
if (control.process.low_delay) {
options.push('-flags', '+low_delay');
}
options.push(...output.options.map((o) => '' + o));
config.output.push({
id: 'output_' + i,
address: output.address,
options: output.options.map((o) => '' + o),
options: options,
});
}

View File

@ -326,13 +326,13 @@ const isSupportedProtocol = (url, supportedProtocols) => {
const getHLSAddress = (host, credentials, name, secure) => {
// Test for IPv6 addresses and put brackets around
let url = 'http' + (secure ? 's' : '') + '://' + (credentials.length !== 0 ? credentials + '@' : '') + host + '/memfs/ingest/' + name + '.m3u8';
let url = 'http' + (secure ? 's' : '') + '://' + (credentials.length !== 0 ? credentials + '@' : '') + host + '/memfs/' + name + '.m3u8';
return url;
};
const getRTMPAddress = (host, app, name, token, secure) => {
let url = 'rtmp' + (secure ? 's' : '') + '://' + host + app + '/ingest/' + name + '.stream';
let url = 'rtmp' + (secure ? 's' : '') + '://' + host + app + '/' + name + '.stream';
if (token.length !== 0) {
url += '?token=' + encodeURIComponent(token);
@ -348,7 +348,7 @@ const getSRTAddress = (host, name, token, passphrase, publish) => {
host +
'?mode=caller&transtype=live&streamid=#!:m=' +
(publish ? 'publish' : 'request') +
',r=ingest/' +
',r=' +
name +
(token.length !== 0 ? ',token=' + encodeURIComponent(token) : '');

View File

@ -436,7 +436,6 @@ export default function Wizard(props) {
);
}
// STEP 3 - Source Probe
// todo: der step kann durch nen backdrop abgelöst werden. dadurch wirkt es schneller
else if ($step === 'VIDEO PROBE') {
return (
<Paper xs={12} md={5} marginBottom="6em" className="PaperM">

View File

@ -40,10 +40,8 @@ export default function Progress(props) {
...divStyle,
};
if (fps && (fps < 10 || speed < 0.8 || speed > 1.2)) {
if (fps && (fps < 10 || speed < 1.0)) {
fpsStyle.backgroundColor = Palette.background.box_danger;
} else if (fps && (speed < 0.9 || speed > 1.1)) {
fpsStyle.backgroundColor = Palette.service.main;
} else {
fpsStyle.backgroundColor = Palette.background.box_default;
}

View File

@ -131,7 +131,7 @@ function Service(props) {
label={<Trans>Stream name</Trans>}
value={settings.stream_name}
onChange={handleChange('stream_name')}
placeholder={settings.protocol !== 'srt' ? 'streamId' : 'ingest/streamId'}
placeholder={'streamId'}
/>
</Grid>
<Grid item xs={12} md={settings.protocol !== 'srt' ? 9 : 4}>