From f443a74649174b2f9347c158e30f8ac7aa3e958a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 4 Mar 2022 13:40:02 +0100 Subject: Add latency setting support --- .../lib/activitypub/videos/shared/object-to-model-attributes.ts | 1 + server/lib/live/live-manager.ts | 7 ++++--- server/lib/live/shared/muxing-session.ts | 9 ++++++++- server/lib/server-config-manager.ts | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) (limited to 'server/lib') diff --git a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts index 1e1479869..c97217669 100644 --- a/server/lib/activitypub/videos/shared/object-to-model-attributes.ts +++ b/server/lib/activitypub/videos/shared/object-to-model-attributes.ts @@ -151,6 +151,7 @@ function getLiveAttributesFromObject (video: MVideoId, videoObject: VideoObject) return { saveReplay: videoObject.liveSaveReplay, permanentLive: videoObject.permanentLive, + latencyMode: videoObject.latencyMode, videoId: video.id } } diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts index 21c34a9a4..920d3a5ec 100644 --- a/server/lib/live/live-manager.ts +++ b/server/lib/live/live-manager.ts @@ -5,9 +5,10 @@ import { createServer as createServerTLS, Server as ServerTLS } from 'tls' import { computeLowerResolutionsToTranscode, ffprobePromise, + getLiveSegmentTime, getVideoStreamBitrate, - getVideoStreamFPS, - getVideoStreamDimensionsInfo + getVideoStreamDimensionsInfo, + getVideoStreamFPS } from '@server/helpers/ffmpeg' import { logger, loggerTagsFactory } from '@server/helpers/logger' import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' @@ -353,7 +354,7 @@ class LiveManager { .catch(err => logger.error('Cannot federate live video %s.', video.url, { err, ...localLTags })) PeerTubeSocket.Instance.sendVideoLiveNewState(video) - }, VIDEO_LIVE.SEGMENT_TIME_SECONDS * 1000 * VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION) + }, getLiveSegmentTime(live.latencyMode) * 1000 * VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION) } catch (err) { logger.error('Cannot save/federate live video %d.', videoId, { err, ...localLTags }) } diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts index f5f473039..a703f5b5f 100644 --- a/server/lib/live/shared/muxing-session.ts +++ b/server/lib/live/shared/muxing-session.ts @@ -125,6 +125,8 @@ class MuxingSession extends EventEmitter { outPath, masterPlaylistName: this.streamingPlaylist.playlistFilename, + latencyMode: this.videoLive.latencyMode, + resolutions: this.allResolutions, fps: this.fps, bitrate: this.bitrate, @@ -133,7 +135,12 @@ class MuxingSession extends EventEmitter { availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(), profile: CONFIG.LIVE.TRANSCODING.PROFILE }) - : getLiveMuxingCommand(this.inputUrl, outPath, this.streamingPlaylist.playlistFilename) + : getLiveMuxingCommand({ + inputUrl: this.inputUrl, + outPath, + masterPlaylistName: this.streamingPlaylist.playlistFilename, + latencyMode: this.videoLive.latencyMode + }) logger.info('Running live muxing/transcoding for %s.', this.videoUUID, this.lTags()) diff --git a/server/lib/server-config-manager.ts b/server/lib/server-config-manager.ts index 43ca2332b..744186cfc 100644 --- a/server/lib/server-config-manager.ts +++ b/server/lib/server-config-manager.ts @@ -137,6 +137,10 @@ class ServerConfigManager { enabled: CONFIG.LIVE.ENABLED, allowReplay: CONFIG.LIVE.ALLOW_REPLAY, + latencySetting: { + enabled: CONFIG.LIVE.LATENCY_SETTING.ENABLED + }, + maxDuration: CONFIG.LIVE.MAX_DURATION, maxInstanceLives: CONFIG.LIVE.MAX_INSTANCE_LIVES, maxUserLives: CONFIG.LIVE.MAX_USER_LIVES, -- cgit v1.2.3