aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/live/live-manager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/live/live-manager.ts')
-rw-r--r--server/lib/live/live-manager.ts29
1 files changed, 15 insertions, 14 deletions
diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts
index aadd8e308..16715862b 100644
--- a/server/lib/live/live-manager.ts
+++ b/server/lib/live/live-manager.ts
@@ -1,4 +1,3 @@
1
2import { readdir, readFile } from 'fs-extra' 1import { readdir, readFile } from 'fs-extra'
3import { createServer, Server } from 'net' 2import { createServer, Server } from 'net'
4import { join } from 'path' 3import { join } from 'path'
@@ -9,7 +8,8 @@ import {
9 getLiveSegmentTime, 8 getLiveSegmentTime,
10 getVideoStreamBitrate, 9 getVideoStreamBitrate,
11 getVideoStreamDimensionsInfo, 10 getVideoStreamDimensionsInfo,
12 getVideoStreamFPS 11 getVideoStreamFPS,
12 hasAudioStream
13} from '@server/helpers/ffmpeg' 13} from '@server/helpers/ffmpeg'
14import { logger, loggerTagsFactory } from '@server/helpers/logger' 14import { logger, loggerTagsFactory } from '@server/helpers/logger'
15import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' 15import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config'
@@ -20,7 +20,7 @@ import { VideoLiveModel } from '@server/models/video/video-live'
20import { VideoLiveSessionModel } from '@server/models/video/video-live-session' 20import { VideoLiveSessionModel } from '@server/models/video/video-live-session'
21import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' 21import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
22import { MStreamingPlaylistVideo, MVideo, MVideoLiveSession, MVideoLiveVideo } from '@server/types/models' 22import { MStreamingPlaylistVideo, MVideo, MVideoLiveSession, MVideoLiveVideo } from '@server/types/models'
23import { wait } from '@shared/core-utils' 23import { pick, wait } from '@shared/core-utils'
24import { LiveVideoError, VideoState, VideoStreamingPlaylistType } from '@shared/models' 24import { LiveVideoError, VideoState, VideoStreamingPlaylistType } from '@shared/models'
25import { federateVideoIfNeeded } from '../activitypub/videos' 25import { federateVideoIfNeeded } from '../activitypub/videos'
26import { JobQueue } from '../job-queue' 26import { JobQueue } from '../job-queue'
@@ -232,10 +232,11 @@ class LiveManager {
232 const now = Date.now() 232 const now = Date.now()
233 const probe = await ffprobePromise(inputUrl) 233 const probe = await ffprobePromise(inputUrl)
234 234
235 const [ { resolution, ratio }, fps, bitrate ] = await Promise.all([ 235 const [ { resolution, ratio }, fps, bitrate, hasAudio ] = await Promise.all([
236 getVideoStreamDimensionsInfo(inputUrl, probe), 236 getVideoStreamDimensionsInfo(inputUrl, probe),
237 getVideoStreamFPS(inputUrl, probe), 237 getVideoStreamFPS(inputUrl, probe),
238 getVideoStreamBitrate(inputUrl, probe) 238 getVideoStreamBitrate(inputUrl, probe),
239 hasAudioStream(inputUrl, probe)
239 ]) 240 ])
240 241
241 logger.info( 242 logger.info(
@@ -259,26 +260,30 @@ class LiveManager {
259 return this.runMuxingSession({ 260 return this.runMuxingSession({
260 sessionId, 261 sessionId,
261 videoLive, 262 videoLive,
263
262 streamingPlaylist, 264 streamingPlaylist,
263 inputUrl, 265 inputUrl,
264 fps, 266 fps,
265 bitrate, 267 bitrate,
266 ratio, 268 ratio,
267 allResolutions 269 allResolutions,
270 hasAudio
268 }) 271 })
269 } 272 }
270 273
271 private async runMuxingSession (options: { 274 private async runMuxingSession (options: {
272 sessionId: string 275 sessionId: string
273 videoLive: MVideoLiveVideo 276 videoLive: MVideoLiveVideo
277
274 streamingPlaylist: MStreamingPlaylistVideo 278 streamingPlaylist: MStreamingPlaylistVideo
275 inputUrl: string 279 inputUrl: string
276 fps: number 280 fps: number
277 bitrate: number 281 bitrate: number
278 ratio: number 282 ratio: number
279 allResolutions: number[] 283 allResolutions: number[]
284 hasAudio: boolean
280 }) { 285 }) {
281 const { sessionId, videoLive, streamingPlaylist, allResolutions, fps, bitrate, ratio, inputUrl } = options 286 const { sessionId, videoLive } = options
282 const videoUUID = videoLive.Video.uuid 287 const videoUUID = videoLive.Video.uuid
283 const localLTags = lTags(sessionId, videoUUID) 288 const localLTags = lTags(sessionId, videoUUID)
284 289
@@ -289,15 +294,11 @@ class LiveManager {
289 294
290 const muxingSession = new MuxingSession({ 295 const muxingSession = new MuxingSession({
291 context: this.getContext(), 296 context: this.getContext(),
292 user,
293 sessionId, 297 sessionId,
294 videoLive, 298 videoLive,
295 streamingPlaylist, 299 user,
296 inputUrl, 300
297 bitrate, 301 ...pick(options, [ 'streamingPlaylist', 'inputUrl', 'bitrate', 'ratio', 'fps', 'allResolutions', 'hasAudio' ])
298 ratio,
299 fps,
300 allResolutions
301 }) 302 })
302 303
303 muxingSession.on('master-playlist-created', () => this.publishAndFederateLive(videoLive, localLTags)) 304 muxingSession.on('master-playlist-created', () => this.publishAndFederateLive(videoLive, localLTags))