diff options
Diffstat (limited to 'server/lib/live')
-rw-r--r-- | server/lib/live/live-manager.ts | 26 | ||||
-rw-r--r-- | server/lib/live/shared/muxing-session.ts | 7 |
2 files changed, 18 insertions, 15 deletions
diff --git a/server/lib/live/live-manager.ts b/server/lib/live/live-manager.ts index da764e009..f106d69fb 100644 --- a/server/lib/live/live-manager.ts +++ b/server/lib/live/live-manager.ts | |||
@@ -4,16 +4,17 @@ import { isTestInstance } from '@server/helpers/core-utils' | |||
4 | import { computeResolutionsToTranscode, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils' | 4 | import { computeResolutionsToTranscode, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils' |
5 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 5 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
6 | import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' | 6 | import { CONFIG, registerConfigChangedHandler } from '@server/initializers/config' |
7 | import { P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, VIEW_LIFETIME, WEBSERVER } from '@server/initializers/constants' | 7 | import { P2P_MEDIA_LOADER_PEER_VERSION, VIDEO_LIVE, VIEW_LIFETIME } from '@server/initializers/constants' |
8 | import { UserModel } from '@server/models/user/user' | 8 | import { UserModel } from '@server/models/user/user' |
9 | import { VideoModel } from '@server/models/video/video' | 9 | import { VideoModel } from '@server/models/video/video' |
10 | import { VideoLiveModel } from '@server/models/video/video-live' | 10 | import { VideoLiveModel } from '@server/models/video/video-live' |
11 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 11 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
12 | import { MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoLiveVideo } from '@server/types/models' | 12 | import { MStreamingPlaylistVideo, MVideo, MVideoLiveVideo } from '@server/types/models' |
13 | import { VideoState, VideoStreamingPlaylistType } from '@shared/models' | 13 | import { VideoState, VideoStreamingPlaylistType } from '@shared/models' |
14 | import { federateVideoIfNeeded } from '../activitypub/videos' | 14 | import { federateVideoIfNeeded } from '../activitypub/videos' |
15 | import { JobQueue } from '../job-queue' | 15 | import { JobQueue } from '../job-queue' |
16 | import { PeerTubeSocket } from '../peertube-socket' | 16 | import { PeerTubeSocket } from '../peertube-socket' |
17 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename } from '../video-paths' | ||
17 | import { LiveQuotaStore } from './live-quota-store' | 18 | import { LiveQuotaStore } from './live-quota-store' |
18 | import { LiveSegmentShaStore } from './live-segment-sha-store' | 19 | import { LiveSegmentShaStore } from './live-segment-sha-store' |
19 | import { cleanupLive } from './live-utils' | 20 | import { cleanupLive } from './live-utils' |
@@ -392,19 +393,18 @@ class LiveManager { | |||
392 | return resolutionsEnabled.concat([ originResolution ]) | 393 | return resolutionsEnabled.concat([ originResolution ]) |
393 | } | 394 | } |
394 | 395 | ||
395 | private async createLivePlaylist (video: MVideo, allResolutions: number[]) { | 396 | private async createLivePlaylist (video: MVideo, allResolutions: number[]): Promise<MStreamingPlaylistVideo> { |
396 | const playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) | 397 | const playlist = await VideoStreamingPlaylistModel.loadOrGenerate(video) |
397 | const [ videoStreamingPlaylist ] = await VideoStreamingPlaylistModel.upsert({ | ||
398 | videoId: video.id, | ||
399 | playlistUrl, | ||
400 | segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid, video.isLive), | ||
401 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, allResolutions), | ||
402 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, | ||
403 | 398 | ||
404 | type: VideoStreamingPlaylistType.HLS | 399 | playlist.playlistFilename = generateHLSMasterPlaylistFilename(true) |
405 | }, { returning: true }) as [ MStreamingPlaylist, boolean ] | 400 | playlist.segmentsSha256Filename = generateHlsSha256SegmentsFilename(true) |
406 | 401 | ||
407 | return Object.assign(videoStreamingPlaylist, { Video: video }) | 402 | playlist.p2pMediaLoaderPeerVersion = P2P_MEDIA_LOADER_PEER_VERSION |
403 | playlist.type = VideoStreamingPlaylistType.HLS | ||
404 | |||
405 | playlist.assignP2PMediaLoaderInfoHashes(video, allResolutions) | ||
406 | |||
407 | return playlist.save() | ||
408 | } | 408 | } |
409 | 409 | ||
410 | static get Instance () { | 410 | static get Instance () { |
diff --git a/server/lib/live/shared/muxing-session.ts b/server/lib/live/shared/muxing-session.ts index 26467f060..709d6c615 100644 --- a/server/lib/live/shared/muxing-session.ts +++ b/server/lib/live/shared/muxing-session.ts | |||
@@ -112,13 +112,16 @@ class MuxingSession extends EventEmitter { | |||
112 | this.ffmpegCommand = CONFIG.LIVE.TRANSCODING.ENABLED | 112 | this.ffmpegCommand = CONFIG.LIVE.TRANSCODING.ENABLED |
113 | ? await getLiveTranscodingCommand({ | 113 | ? await getLiveTranscodingCommand({ |
114 | rtmpUrl: this.rtmpUrl, | 114 | rtmpUrl: this.rtmpUrl, |
115 | |||
115 | outPath, | 116 | outPath, |
117 | masterPlaylistName: this.streamingPlaylist.playlistFilename, | ||
118 | |||
116 | resolutions: this.allResolutions, | 119 | resolutions: this.allResolutions, |
117 | fps: this.fps, | 120 | fps: this.fps, |
118 | availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(), | 121 | availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(), |
119 | profile: CONFIG.LIVE.TRANSCODING.PROFILE | 122 | profile: CONFIG.LIVE.TRANSCODING.PROFILE |
120 | }) | 123 | }) |
121 | : getLiveMuxingCommand(this.rtmpUrl, outPath) | 124 | : getLiveMuxingCommand(this.rtmpUrl, outPath, this.streamingPlaylist.playlistFilename) |
122 | 125 | ||
123 | logger.info('Running live muxing/transcoding for %s.', this.videoUUID, this.lTags) | 126 | logger.info('Running live muxing/transcoding for %s.', this.videoUUID, this.lTags) |
124 | 127 | ||
@@ -182,7 +185,7 @@ class MuxingSession extends EventEmitter { | |||
182 | } | 185 | } |
183 | 186 | ||
184 | private watchMasterFile (outPath: string) { | 187 | private watchMasterFile (outPath: string) { |
185 | this.masterWatcher = chokidar.watch(outPath + '/master.m3u8') | 188 | this.masterWatcher = chokidar.watch(outPath + '/' + this.streamingPlaylist.playlistFilename) |
186 | 189 | ||
187 | this.masterWatcher.on('add', async () => { | 190 | this.masterWatcher.on('add', async () => { |
188 | this.emit('master-playlist-created', { videoId: this.videoId }) | 191 | this.emit('master-playlist-created', { videoId: this.videoId }) |