aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-paths.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/video-paths.ts')
-rw-r--r--server/lib/video-paths.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/server/lib/video-paths.ts b/server/lib/video-paths.ts
index b7068190c..1e4382108 100644
--- a/server/lib/video-paths.ts
+++ b/server/lib/video-paths.ts
@@ -4,19 +4,16 @@ import { CONFIG } from '@server/initializers/config'
4import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants' 4import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY, STATIC_PATHS, WEBSERVER } from '@server/initializers/constants'
5import { isStreamingPlaylist, MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' 5import { isStreamingPlaylist, MStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models'
6import { buildUUID } from '@server/helpers/uuid' 6import { buildUUID } from '@server/helpers/uuid'
7import { removeFragmentedMP4Ext } from '@shared/core-utils'
7 8
8// ################## Video file name ################## 9// ################## Video file name ##################
9 10
10function generateWebTorrentVideoFilename (resolution: number, extname: string) { 11function generateWebTorrentVideoFilename (resolution: number, extname: string) {
11 const uuid = buildUUID() 12 return buildUUID() + '-' + resolution + extname
12
13 return uuid + '-' + resolution + extname
14} 13}
15 14
16function generateHLSVideoFilename (resolution: number) { 15function generateHLSVideoFilename (resolution: number) {
17 const uuid = buildUUID() 16 return `${buildUUID()}-${resolution}-fragmented.mp4`
18
19 return `${uuid}-${resolution}-fragmented.mp4`
20} 17}
21 18
22function getVideoFilePath (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, isRedundancy = false) { 19function getVideoFilePath (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, isRedundancy = false) {
@@ -54,6 +51,23 @@ function getHLSDirectory (video: MVideoUUID, isRedundancy = false) {
54 return join(baseDir, video.uuid) 51 return join(baseDir, video.uuid)
55} 52}
56 53
54function getHlsResolutionPlaylistFilename (videoFilename: string) {
55 // Video file name already contain resolution
56 return removeFragmentedMP4Ext(videoFilename) + '.m3u8'
57}
58
59function generateHLSMasterPlaylistFilename (isLive = false) {
60 if (isLive) return 'master.m3u8'
61
62 return buildUUID() + '-master.m3u8'
63}
64
65function generateHlsSha256SegmentsFilename (isLive = false) {
66 if (isLive) return 'segments-sha256.json'
67
68 return buildUUID() + '-segments-sha256.json'
69}
70
57// ################## Torrents ################## 71// ################## Torrents ##################
58 72
59function generateTorrentFileName (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, resolution: number) { 73function generateTorrentFileName (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, resolution: number) {
@@ -91,6 +105,9 @@ export {
91 getTorrentFilePath, 105 getTorrentFilePath,
92 106
93 getHLSDirectory, 107 getHLSDirectory,
108 generateHLSMasterPlaylistFilename,
109 generateHlsSha256SegmentsFilename,
110 getHlsResolutionPlaylistFilename,
94 111
95 getLocalVideoFileMetadataUrl, 112 getLocalVideoFileMetadataUrl,
96 113