diff options
author | Chocobozzz <me@florianbigard.com> | 2021-11-18 14:35:08 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-11-18 15:20:57 +0100 |
commit | ad5db1044c8599eaaaa2a578b350777ae996b068 (patch) | |
tree | 3e003cccf021152405d49b21c6c91b703c8ae96c /server/lib/video-path-manager.ts | |
parent | b46cf4b920984492df598c1b61179acfc7f6f22e (diff) | |
download | PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.gz PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.tar.zst PeerTube-ad5db1044c8599eaaaa2a578b350777ae996b068.zip |
Add ability to run transcoding jobs
Diffstat (limited to 'server/lib/video-path-manager.ts')
-rw-r--r-- | server/lib/video-path-manager.ts | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/server/lib/video-path-manager.ts b/server/lib/video-path-manager.ts index 4c5d0c89d..27058005c 100644 --- a/server/lib/video-path-manager.ts +++ b/server/lib/video-path-manager.ts | |||
@@ -3,7 +3,14 @@ import { extname, join } from 'path' | |||
3 | import { buildUUID } from '@server/helpers/uuid' | 3 | import { buildUUID } from '@server/helpers/uuid' |
4 | import { extractVideo } from '@server/helpers/video' | 4 | import { extractVideo } from '@server/helpers/video' |
5 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
6 | import { MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models' | 6 | import { |
7 | MStreamingPlaylistVideo, | ||
8 | MVideo, | ||
9 | MVideoFile, | ||
10 | MVideoFileStreamingPlaylistVideo, | ||
11 | MVideoFileVideo, | ||
12 | MVideoUUID | ||
13 | } from '@server/types/models' | ||
7 | import { VideoStorage } from '@shared/models' | 14 | import { VideoStorage } from '@shared/models' |
8 | import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage' | 15 | import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage' |
9 | import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths' | 16 | import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths' |
@@ -43,10 +50,10 @@ class VideoPathManager { | |||
43 | return join(CONFIG.STORAGE.VIDEOS_DIR, videoFile.filename) | 50 | return join(CONFIG.STORAGE.VIDEOS_DIR, videoFile.filename) |
44 | } | 51 | } |
45 | 52 | ||
46 | async makeAvailableVideoFile <T> (videoOrPlaylist: MVideo | MStreamingPlaylistVideo, videoFile: MVideoFile, cb: MakeAvailableCB<T>) { | 53 | async makeAvailableVideoFile <T> (videoFile: MVideoFileVideo | MVideoFileStreamingPlaylistVideo, cb: MakeAvailableCB<T>) { |
47 | if (videoFile.storage === VideoStorage.FILE_SYSTEM) { | 54 | if (videoFile.storage === VideoStorage.FILE_SYSTEM) { |
48 | return this.makeAvailableFactory( | 55 | return this.makeAvailableFactory( |
49 | () => this.getFSVideoFileOutputPath(videoOrPlaylist, videoFile), | 56 | () => this.getFSVideoFileOutputPath(videoFile.getVideoOrStreamingPlaylist(), videoFile), |
50 | false, | 57 | false, |
51 | cb | 58 | cb |
52 | ) | 59 | ) |
@@ -55,10 +62,10 @@ class VideoPathManager { | |||
55 | const destination = this.buildTMPDestination(videoFile.filename) | 62 | const destination = this.buildTMPDestination(videoFile.filename) |
56 | 63 | ||
57 | if (videoFile.isHLS()) { | 64 | if (videoFile.isHLS()) { |
58 | const video = extractVideo(videoOrPlaylist) | 65 | const playlist = (videoFile as MVideoFileStreamingPlaylistVideo).VideoStreamingPlaylist |
59 | 66 | ||
60 | return this.makeAvailableFactory( | 67 | return this.makeAvailableFactory( |
61 | () => makeHLSFileAvailable(videoOrPlaylist as MStreamingPlaylistVideo, video, videoFile.filename, destination), | 68 | () => makeHLSFileAvailable(playlist, videoFile.filename, destination), |
62 | true, | 69 | true, |
63 | cb | 70 | cb |
64 | ) | 71 | ) |
@@ -71,19 +78,20 @@ class VideoPathManager { | |||
71 | ) | 78 | ) |
72 | } | 79 | } |
73 | 80 | ||
74 | async makeAvailableResolutionPlaylistFile <T> (playlist: MStreamingPlaylistVideo, videoFile: MVideoFile, cb: MakeAvailableCB<T>) { | 81 | async makeAvailableResolutionPlaylistFile <T> (videoFile: MVideoFileStreamingPlaylistVideo, cb: MakeAvailableCB<T>) { |
75 | const filename = getHlsResolutionPlaylistFilename(videoFile.filename) | 82 | const filename = getHlsResolutionPlaylistFilename(videoFile.filename) |
76 | 83 | ||
77 | if (videoFile.storage === VideoStorage.FILE_SYSTEM) { | 84 | if (videoFile.storage === VideoStorage.FILE_SYSTEM) { |
78 | return this.makeAvailableFactory( | 85 | return this.makeAvailableFactory( |
79 | () => join(getHLSDirectory(playlist.Video), filename), | 86 | () => join(getHLSDirectory(videoFile.getVideo()), filename), |
80 | false, | 87 | false, |
81 | cb | 88 | cb |
82 | ) | 89 | ) |
83 | } | 90 | } |
84 | 91 | ||
92 | const playlist = videoFile.VideoStreamingPlaylist | ||
85 | return this.makeAvailableFactory( | 93 | return this.makeAvailableFactory( |
86 | () => makeHLSFileAvailable(playlist, playlist.Video, filename, this.buildTMPDestination(filename)), | 94 | () => makeHLSFileAvailable(playlist, filename, this.buildTMPDestination(filename)), |
87 | true, | 95 | true, |
88 | cb | 96 | cb |
89 | ) | 97 | ) |
@@ -99,7 +107,7 @@ class VideoPathManager { | |||
99 | } | 107 | } |
100 | 108 | ||
101 | return this.makeAvailableFactory( | 109 | return this.makeAvailableFactory( |
102 | () => makeHLSFileAvailable(playlist, playlist.Video, filename, this.buildTMPDestination(filename)), | 110 | () => makeHLSFileAvailable(playlist, filename, this.buildTMPDestination(filename)), |
103 | true, | 111 | true, |
104 | cb | 112 | cb |
105 | ) | 113 | ) |