diff options
Diffstat (limited to 'server/lib/video-transcoding.ts')
-rw-r--r-- | server/lib/video-transcoding.ts | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index a7b73a30d..c62b3c1ce 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts | |||
@@ -147,17 +147,18 @@ async function mergeAudioVideofile (video: MVideoWithAllFiles, resolution: Video | |||
147 | return onVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath) | 147 | return onVideoFileTranscoding(video, inputVideoFile, videoTranscodedPath, videoOutputPath) |
148 | } | 148 | } |
149 | 149 | ||
150 | async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoResolution, copyCodecs: boolean, isPortraitMode: boolean) { | 150 | async function generateHlsPlaylist (options: { |
151 | video: MVideoWithFile | ||
152 | videoInputPath: string | ||
153 | resolution: VideoResolution | ||
154 | copyCodecs: boolean | ||
155 | isPortraitMode: boolean | ||
156 | }) { | ||
157 | const { video, videoInputPath, resolution, copyCodecs, isPortraitMode } = options | ||
158 | |||
151 | const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) | 159 | const baseHlsDirectory = join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid) |
152 | await ensureDir(join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)) | 160 | await ensureDir(join(HLS_STREAMING_PLAYLIST_DIRECTORY, video.uuid)) |
153 | 161 | ||
154 | const videoFileInput = copyCodecs | ||
155 | ? video.getWebTorrentFile(resolution) | ||
156 | : video.getMaxQualityFile() | ||
157 | |||
158 | const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist() | ||
159 | const videoInputPath = getVideoFilePath(videoOrStreamingPlaylist, videoFileInput) | ||
160 | |||
161 | const outputPath = join(baseHlsDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)) | 162 | const outputPath = join(baseHlsDirectory, VideoStreamingPlaylistModel.getHlsPlaylistFilename(resolution)) |
162 | const videoFilename = generateVideoStreamingPlaylistName(video.uuid, resolution) | 163 | const videoFilename = generateVideoStreamingPlaylistName(video.uuid, resolution) |
163 | 164 | ||
@@ -184,7 +185,7 @@ async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoReso | |||
184 | videoId: video.id, | 185 | videoId: video.id, |
185 | playlistUrl, | 186 | playlistUrl, |
186 | segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid, video.isLive), | 187 | segmentsSha256Url: WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsSha256SegmentsStaticPath(video.uuid, video.isLive), |
187 | p2pMediaLoaderInfohashes: VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes(playlistUrl, video.VideoFiles), | 188 | p2pMediaLoaderInfohashes: [], |
188 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, | 189 | p2pMediaLoaderPeerVersion: P2P_MEDIA_LOADER_PEER_VERSION, |
189 | 190 | ||
190 | type: VideoStreamingPlaylistType.HLS | 191 | type: VideoStreamingPlaylistType.HLS |
@@ -211,6 +212,11 @@ async function generateHlsPlaylist (video: MVideoWithFile, resolution: VideoReso | |||
211 | await VideoFileModel.customUpsert(newVideoFile, 'streaming-playlist', undefined) | 212 | await VideoFileModel.customUpsert(newVideoFile, 'streaming-playlist', undefined) |
212 | videoStreamingPlaylist.VideoFiles = await videoStreamingPlaylist.$get('VideoFiles') | 213 | videoStreamingPlaylist.VideoFiles = await videoStreamingPlaylist.$get('VideoFiles') |
213 | 214 | ||
215 | videoStreamingPlaylist.p2pMediaLoaderInfohashes = VideoStreamingPlaylistModel.buildP2PMediaLoaderInfoHashes( | ||
216 | playlistUrl, videoStreamingPlaylist.VideoFiles | ||
217 | ) | ||
218 | await videoStreamingPlaylist.save() | ||
219 | |||
214 | video.setHLSPlaylist(videoStreamingPlaylist) | 220 | video.setHLSPlaylist(videoStreamingPlaylist) |
215 | 221 | ||
216 | await updateMasterHLSPlaylist(video) | 222 | await updateMasterHLSPlaylist(video) |