Make HLS segment length configurable.
This commit is contained in:
parent
9951fee7dc
commit
7bb92404e7
|
@ -83,6 +83,24 @@
|
|||
</b-form-row>
|
||||
</b-form-fieldset>
|
||||
|
||||
<b-form-fieldset v-if="showAdvanced && form.enable_hls.$model">
|
||||
<template #label>
|
||||
<translate key="lang_hls">HTTP Live Streaming (HLS)</translate>
|
||||
</template>
|
||||
|
||||
<b-form-fieldset>
|
||||
<b-form-row>
|
||||
<b-wrapped-form-group class="col-md-6" id="edit_form_backend_hls_segment_length"
|
||||
:field="form.backend_config.hls_segment_length" input-type="number"
|
||||
:input-attrs="{ min: '0', max: '60' }" advanced>
|
||||
<template #label="{lang}">
|
||||
<translate :key="lang">Segment Length (Seconds)</translate>
|
||||
</template>
|
||||
</b-wrapped-form-group>
|
||||
</b-form-row>
|
||||
</b-form-fieldset>
|
||||
</b-form-fieldset>
|
||||
|
||||
<b-form-fieldset v-if="isStereoToolEnabled && isStereoToolInstalled">
|
||||
<template #label>
|
||||
<translate key="lang_hdr_stereo_tool">Stereo Tool</translate>
|
||||
|
|
|
@ -188,6 +188,7 @@ export default {
|
|||
banned_user_agents: {}
|
||||
},
|
||||
backend_config: {
|
||||
hls_segment_length: {numeric},
|
||||
dj_port: {numeric},
|
||||
telnet_port: {numeric},
|
||||
dj_mount_point: {},
|
||||
|
@ -326,6 +327,7 @@ export default {
|
|||
banned_user_agents: '',
|
||||
},
|
||||
backend_config: {
|
||||
hls_segment_length: 4,
|
||||
dj_port: '',
|
||||
telnet_port: '',
|
||||
dj_mount_point: '/',
|
||||
|
|
|
@ -307,6 +307,18 @@ class StationBackendConfiguration extends AbstractStationConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
public const HLS_SEGMENT_LENGTH = 'hls_segment_length';
|
||||
|
||||
public function getHlsSegmentLength(): int
|
||||
{
|
||||
return $this->get(self::HLS_SEGMENT_LENGTH, 4);
|
||||
}
|
||||
|
||||
public function setHlsSegmentLength(?int $length): void
|
||||
{
|
||||
$this->set(self::HLS_SEGMENT_LENGTH, $length);
|
||||
}
|
||||
|
||||
public const CUSTOM_TOP = 'custom_config_top';
|
||||
public const CUSTOM_PRE_PLAYLISTS = 'custom_config_pre_playlists';
|
||||
public const CUSTOM_PRE_LIVE = 'custom_config_pre_live';
|
||||
|
|
|
@ -1148,17 +1148,18 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
$configDir = $station->getRadioConfigDir();
|
||||
$hlsBaseDir = $station->getRadioHlsDir();
|
||||
$hlsSegmentLength = $station->getBackendConfig()->getHlsSegmentLength();
|
||||
|
||||
$event->appendBlock(
|
||||
<<<LS
|
||||
def hls_segment_name(~position,~extname,stream_name) =
|
||||
timestamp = int_of_float(time())
|
||||
duration = 4
|
||||
duration = {$hlsSegmentLength}
|
||||
"#{stream_name}_#{duration}_#{timestamp}_#{position}.#{extname}"
|
||||
end
|
||||
|
||||
output.file.hls(playlist="live.m3u8",
|
||||
segment_duration=4.0,
|
||||
segment_duration={$hlsSegmentLength}.0,
|
||||
segments=5,
|
||||
segments_overhead=5,
|
||||
segment_name=hls_segment_name,
|
||||
|
|
Loading…
Reference in New Issue