diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:21:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-11 09:21:13 +0200 |
commit | 784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428 (patch) | |
tree | 29c46cfd6344065eb805680ed080cb05592ee1d4 /server/lib/job-queue | |
parent | c3030e944ad03c7fd7b5d668a2d88ff03e4cdf19 (diff) | |
download | PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.gz PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.zst PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.zip |
Prefer web videos in favour of webtorrent
Diffstat (limited to 'server/lib/job-queue')
4 files changed, 26 insertions, 26 deletions
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts index 26752ff37..9a99b6722 100644 --- a/server/lib/job-queue/handlers/move-to-object-storage.ts +++ b/server/lib/job-queue/handlers/move-to-object-storage.ts | |||
@@ -4,7 +4,7 @@ import { join } from 'path' | |||
4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' | 4 | import { logger, loggerTagsFactory } from '@server/helpers/logger' |
5 | import { updateTorrentMetadata } from '@server/helpers/webtorrent' | 5 | import { updateTorrentMetadata } from '@server/helpers/webtorrent' |
6 | import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants' | 6 | import { P2P_MEDIA_LOADER_PEER_VERSION } from '@server/initializers/constants' |
7 | import { storeHLSFileFromFilename, storeWebTorrentFile } from '@server/lib/object-storage' | 7 | import { storeHLSFileFromFilename, storeWebVideoFile } from '@server/lib/object-storage' |
8 | import { getHLSDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths' | 8 | import { getHLSDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths' |
9 | import { VideoPathManager } from '@server/lib/video-path-manager' | 9 | import { VideoPathManager } from '@server/lib/video-path-manager' |
10 | import { moveToFailedMoveToObjectStorageState, moveToNextState } from '@server/lib/video-state' | 10 | import { moveToFailedMoveToObjectStorageState, moveToNextState } from '@server/lib/video-state' |
@@ -33,9 +33,9 @@ export async function processMoveToObjectStorage (job: Job) { | |||
33 | 33 | ||
34 | try { | 34 | try { |
35 | if (video.VideoFiles) { | 35 | if (video.VideoFiles) { |
36 | logger.debug('Moving %d webtorrent files for video %s.', video.VideoFiles.length, video.uuid, lTags) | 36 | logger.debug('Moving %d web video files for video %s.', video.VideoFiles.length, video.uuid, lTags) |
37 | 37 | ||
38 | await moveWebTorrentFiles(video) | 38 | await moveWebVideoFiles(video) |
39 | } | 39 | } |
40 | 40 | ||
41 | if (video.VideoStreamingPlaylists) { | 41 | if (video.VideoStreamingPlaylists) { |
@@ -75,11 +75,11 @@ export async function onMoveToObjectStorageFailure (job: Job, err: any) { | |||
75 | 75 | ||
76 | // --------------------------------------------------------------------------- | 76 | // --------------------------------------------------------------------------- |
77 | 77 | ||
78 | async function moveWebTorrentFiles (video: MVideoWithAllFiles) { | 78 | async function moveWebVideoFiles (video: MVideoWithAllFiles) { |
79 | for (const file of video.VideoFiles) { | 79 | for (const file of video.VideoFiles) { |
80 | if (file.storage !== VideoStorage.FILE_SYSTEM) continue | 80 | if (file.storage !== VideoStorage.FILE_SYSTEM) continue |
81 | 81 | ||
82 | const fileUrl = await storeWebTorrentFile(video, file) | 82 | const fileUrl = await storeWebVideoFile(video, file) |
83 | 83 | ||
84 | const oldPath = VideoPathManager.Instance.getFSVideoFileOutputPath(video, file) | 84 | const oldPath = VideoPathManager.Instance.getFSVideoFileOutputPath(video, file) |
85 | await onFileMoved({ videoOrPlaylist: video, file, fileUrl, oldPath }) | 85 | await onFileMoved({ videoOrPlaylist: video, file, fileUrl, oldPath }) |
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts index 9a4550e4d..d221e8968 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/lib/job-queue/handlers/video-file-import.ts | |||
@@ -3,7 +3,7 @@ import { copy, stat } from 'fs-extra' | |||
3 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 3 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
4 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
5 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' | 5 | import { federateVideoIfNeeded } from '@server/lib/activitypub/videos' |
6 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' | 6 | import { generateWebVideoFilename } from '@server/lib/paths' |
7 | import { buildMoveToObjectStorageJob } from '@server/lib/video' | 7 | import { buildMoveToObjectStorageJob } from '@server/lib/video' |
8 | import { VideoPathManager } from '@server/lib/video-path-manager' | 8 | import { VideoPathManager } from '@server/lib/video-path-manager' |
9 | import { VideoModel } from '@server/models/video/video' | 9 | import { VideoModel } from '@server/models/video/video' |
@@ -56,7 +56,7 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) { | |||
56 | 56 | ||
57 | if (currentVideoFile) { | 57 | if (currentVideoFile) { |
58 | // Remove old file and old torrent | 58 | // Remove old file and old torrent |
59 | await video.removeWebTorrentFile(currentVideoFile) | 59 | await video.removeWebVideoFile(currentVideoFile) |
60 | // Remove the old video file from the array | 60 | // Remove the old video file from the array |
61 | video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile) | 61 | video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile) |
62 | 62 | ||
@@ -66,7 +66,7 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) { | |||
66 | const newVideoFile = new VideoFileModel({ | 66 | const newVideoFile = new VideoFileModel({ |
67 | resolution, | 67 | resolution, |
68 | extname: fileExt, | 68 | extname: fileExt, |
69 | filename: generateWebTorrentVideoFilename(resolution, fileExt), | 69 | filename: generateWebVideoFilename(resolution, fileExt), |
70 | storage: VideoStorage.FILE_SYSTEM, | 70 | storage: VideoStorage.FILE_SYSTEM, |
71 | size, | 71 | size, |
72 | fps, | 72 | fps, |
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 436bf3175..e5cd258d6 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -4,7 +4,7 @@ import { retryTransactionWrapper } from '@server/helpers/database-utils' | |||
4 | import { YoutubeDLWrapper } from '@server/helpers/youtube-dl' | 4 | import { YoutubeDLWrapper } from '@server/helpers/youtube-dl' |
5 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
6 | import { isPostImportVideoAccepted } from '@server/lib/moderation' | 6 | import { isPostImportVideoAccepted } from '@server/lib/moderation' |
7 | import { generateWebTorrentVideoFilename } from '@server/lib/paths' | 7 | import { generateWebVideoFilename } from '@server/lib/paths' |
8 | import { Hooks } from '@server/lib/plugins/hooks' | 8 | import { Hooks } from '@server/lib/plugins/hooks' |
9 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 9 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
10 | import { createOptimizeOrMergeAudioJobs } from '@server/lib/transcoding/create-transcoding-job' | 10 | import { createOptimizeOrMergeAudioJobs } from '@server/lib/transcoding/create-transcoding-job' |
@@ -148,7 +148,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid | |||
148 | extname: fileExt, | 148 | extname: fileExt, |
149 | resolution, | 149 | resolution, |
150 | size: stats.size, | 150 | size: stats.size, |
151 | filename: generateWebTorrentVideoFilename(resolution, fileExt), | 151 | filename: generateWebVideoFilename(resolution, fileExt), |
152 | fps, | 152 | fps, |
153 | videoId: videoImport.videoId | 153 | videoId: videoImport.videoId |
154 | } | 154 | } |
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index f8758f170..1c8f4fd9f 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { Job } from 'bullmq' | 1 | import { Job } from 'bullmq' |
2 | import { onTranscodingEnded } from '@server/lib/transcoding/ended-transcoding' | 2 | import { onTranscodingEnded } from '@server/lib/transcoding/ended-transcoding' |
3 | import { generateHlsPlaylistResolution } from '@server/lib/transcoding/hls-transcoding' | 3 | import { generateHlsPlaylistResolution } from '@server/lib/transcoding/hls-transcoding' |
4 | import { mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewWebTorrentResolution } from '@server/lib/transcoding/web-transcoding' | 4 | import { mergeAudioVideofile, optimizeOriginalVideofile, transcodeNewWebVideoResolution } from '@server/lib/transcoding/web-transcoding' |
5 | import { removeAllWebTorrentFiles } from '@server/lib/video-file' | 5 | import { removeAllWebVideoFiles } from '@server/lib/video-file' |
6 | import { VideoPathManager } from '@server/lib/video-path-manager' | 6 | import { VideoPathManager } from '@server/lib/video-path-manager' |
7 | import { moveToFailedTranscodingState } from '@server/lib/video-state' | 7 | import { moveToFailedTranscodingState } from '@server/lib/video-state' |
8 | import { UserModel } from '@server/models/user/user' | 8 | import { UserModel } from '@server/models/user/user' |
@@ -11,7 +11,7 @@ import { MUser, MUserId, MVideoFullLight } from '@server/types/models' | |||
11 | import { | 11 | import { |
12 | HLSTranscodingPayload, | 12 | HLSTranscodingPayload, |
13 | MergeAudioTranscodingPayload, | 13 | MergeAudioTranscodingPayload, |
14 | NewWebTorrentResolutionTranscodingPayload, | 14 | NewWebVideoResolutionTranscodingPayload, |
15 | OptimizeTranscodingPayload, | 15 | OptimizeTranscodingPayload, |
16 | VideoTranscodingPayload | 16 | VideoTranscodingPayload |
17 | } from '@shared/models' | 17 | } from '@shared/models' |
@@ -22,9 +22,9 @@ type HandlerFunction = (job: Job, payload: VideoTranscodingPayload, video: MVide | |||
22 | 22 | ||
23 | const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { | 23 | const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { |
24 | 'new-resolution-to-hls': handleHLSJob, | 24 | 'new-resolution-to-hls': handleHLSJob, |
25 | 'new-resolution-to-webtorrent': handleNewWebTorrentResolutionJob, | 25 | 'new-resolution-to-web-video': handleNewWebVideoResolutionJob, |
26 | 'merge-audio-to-webtorrent': handleWebTorrentMergeAudioJob, | 26 | 'merge-audio-to-web-video': handleWebVideoMergeAudioJob, |
27 | 'optimize-to-webtorrent': handleWebTorrentOptimizeJob | 27 | 'optimize-to-web-video': handleWebVideoOptimizeJob |
28 | } | 28 | } |
29 | 29 | ||
30 | const lTags = loggerTagsFactory('transcoding') | 30 | const lTags = loggerTagsFactory('transcoding') |
@@ -74,7 +74,7 @@ export { | |||
74 | // Job handlers | 74 | // Job handlers |
75 | // --------------------------------------------------------------------------- | 75 | // --------------------------------------------------------------------------- |
76 | 76 | ||
77 | async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { | 77 | async function handleWebVideoMergeAudioJob (job: Job, payload: MergeAudioTranscodingPayload, video: MVideoFullLight, user: MUserId) { |
78 | logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid), { payload }) | 78 | logger.info('Handling merge audio transcoding job for %s.', video.uuid, lTags(video.uuid), { payload }) |
79 | 79 | ||
80 | await mergeAudioVideofile({ video, resolution: payload.resolution, fps: payload.fps, job }) | 80 | await mergeAudioVideofile({ video, resolution: payload.resolution, fps: payload.fps, job }) |
@@ -84,7 +84,7 @@ async function handleWebTorrentMergeAudioJob (job: Job, payload: MergeAudioTrans | |||
84 | await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video }) | 84 | await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: !payload.hasChildren, video }) |
85 | } | 85 | } |
86 | 86 | ||
87 | async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { | 87 | async function handleWebVideoOptimizeJob (job: Job, payload: OptimizeTranscodingPayload, video: MVideoFullLight, user: MUserId) { |
88 | logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid), { payload }) | 88 | logger.info('Handling optimize transcoding job for %s.', video.uuid, lTags(video.uuid), { payload }) |
89 | 89 | ||
90 | await optimizeOriginalVideofile({ video, inputVideoFile: video.getMaxQualityFile(), quickTranscode: payload.quickTranscode, job }) | 90 | await optimizeOriginalVideofile({ video, inputVideoFile: video.getMaxQualityFile(), quickTranscode: payload.quickTranscode, job }) |
@@ -96,12 +96,12 @@ async function handleWebTorrentOptimizeJob (job: Job, payload: OptimizeTranscodi | |||
96 | 96 | ||
97 | // --------------------------------------------------------------------------- | 97 | // --------------------------------------------------------------------------- |
98 | 98 | ||
99 | async function handleNewWebTorrentResolutionJob (job: Job, payload: NewWebTorrentResolutionTranscodingPayload, video: MVideoFullLight) { | 99 | async function handleNewWebVideoResolutionJob (job: Job, payload: NewWebVideoResolutionTranscodingPayload, video: MVideoFullLight) { |
100 | logger.info('Handling WebTorrent transcoding job for %s.', video.uuid, lTags(video.uuid), { payload }) | 100 | logger.info('Handling Web Video transcoding job for %s.', video.uuid, lTags(video.uuid), { payload }) |
101 | 101 | ||
102 | await transcodeNewWebTorrentResolution({ video, resolution: payload.resolution, fps: payload.fps, job }) | 102 | await transcodeNewWebVideoResolution({ video, resolution: payload.resolution, fps: payload.fps, job }) |
103 | 103 | ||
104 | logger.info('WebTorrent transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload }) | 104 | logger.info('Web Video transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload }) |
105 | 105 | ||
106 | await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video }) | 106 | await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video }) |
107 | } | 107 | } |
@@ -118,7 +118,7 @@ async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: | |||
118 | video = await VideoModel.loadFull(videoArg.uuid) | 118 | video = await VideoModel.loadFull(videoArg.uuid) |
119 | 119 | ||
120 | const videoFileInput = payload.copyCodecs | 120 | const videoFileInput = payload.copyCodecs |
121 | ? video.getWebTorrentFile(payload.resolution) | 121 | ? video.getWebVideoFile(payload.resolution) |
122 | : video.getMaxQualityFile() | 122 | : video.getMaxQualityFile() |
123 | 123 | ||
124 | const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist() | 124 | const videoOrStreamingPlaylist = videoFileInput.getVideoOrStreamingPlaylist() |
@@ -140,10 +140,10 @@ async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, videoArg: | |||
140 | 140 | ||
141 | logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload }) | 141 | logger.info('HLS transcoding job for %s ended.', video.uuid, lTags(video.uuid), { payload }) |
142 | 142 | ||
143 | if (payload.deleteWebTorrentFiles === true) { | 143 | if (payload.deleteWebVideoFiles === true) { |
144 | logger.info('Removing WebTorrent files of %s now we have a HLS version of it.', video.uuid, lTags(video.uuid)) | 144 | logger.info('Removing Web Video files of %s now we have a HLS version of it.', video.uuid, lTags(video.uuid)) |
145 | 145 | ||
146 | await removeAllWebTorrentFiles(video) | 146 | await removeAllWebVideoFiles(video) |
147 | } | 147 | } |
148 | 148 | ||
149 | await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video }) | 149 | await onTranscodingEnded({ isNewVideo: payload.isNewVideo, moveVideoToNextState: true, video }) |