diff options
author | Chocobozzz <me@florianbigard.com> | 2022-02-01 11:16:45 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-02-01 11:27:38 +0100 |
commit | 0f11ec8dd32b50897c18588db948e96cf0fc2c70 (patch) | |
tree | 49be9328b4dd5ac8d989ccbe157f494d85246618 /server | |
parent | 3e8c3fcdb063e2d8f4b3ba04fdcdeda588538751 (diff) | |
download | PeerTube-0f11ec8dd32b50897c18588db948e96cf0fc2c70.tar.gz PeerTube-0f11ec8dd32b50897c18588db948e96cf0fc2c70.tar.zst PeerTube-0f11ec8dd32b50897c18588db948e96cf0fc2c70.zip |
Prevent HLS transcoding after webtorrent transcoding
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/videos/transcoding.ts | 5 | ||||
-rw-r--r-- | server/lib/job-queue/handlers/video-transcoding.ts | 12 | ||||
-rw-r--r-- | server/lib/video.ts | 1 | ||||
-rw-r--r-- | server/tests/api/videos/video-create-transcoding.ts | 25 |
4 files changed, 36 insertions, 7 deletions
diff --git a/server/controllers/api/videos/transcoding.ts b/server/controllers/api/videos/transcoding.ts index 388689c8a..fba4545c2 100644 --- a/server/controllers/api/videos/transcoding.ts +++ b/server/controllers/api/videos/transcoding.ts | |||
@@ -25,7 +25,7 @@ export { | |||
25 | 25 | ||
26 | async function createTranscoding (req: express.Request, res: express.Response) { | 26 | async function createTranscoding (req: express.Request, res: express.Response) { |
27 | const video = res.locals.videoAll | 27 | const video = res.locals.videoAll |
28 | logger.info('Creating %s transcoding job for %s.', req.body.type, video.url, lTags()) | 28 | logger.info('Creating %s transcoding job for %s.', req.body.transcodingType, video.url, lTags()) |
29 | 29 | ||
30 | const body: VideoTranscodingCreate = req.body | 30 | const body: VideoTranscodingCreate = req.body |
31 | 31 | ||
@@ -53,8 +53,9 @@ async function createTranscoding (req: express.Request, res: express.Response) { | |||
53 | type: 'new-resolution-to-webtorrent', | 53 | type: 'new-resolution-to-webtorrent', |
54 | videoUUID: video.uuid, | 54 | videoUUID: video.uuid, |
55 | isNewVideo: false, | 55 | isNewVideo: false, |
56 | resolution: resolution, | 56 | resolution, |
57 | hasAudio: !!audioStream, | 57 | hasAudio: !!audioStream, |
58 | createHLSIfNeeded: false, | ||
58 | isPortraitMode | 59 | isPortraitMode |
59 | }) | 60 | }) |
60 | } | 61 | } |
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index 02902b0b8..5540b791d 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -10,7 +10,7 @@ import { pick } from '@shared/core-utils' | |||
10 | import { | 10 | import { |
11 | HLSTranscodingPayload, | 11 | HLSTranscodingPayload, |
12 | MergeAudioTranscodingPayload, | 12 | MergeAudioTranscodingPayload, |
13 | NewResolutionTranscodingPayload, | 13 | NewWebTorrentResolutionTranscodingPayload, |
14 | OptimizeTranscodingPayload, | 14 | OptimizeTranscodingPayload, |
15 | VideoResolution, | 15 | VideoResolution, |
16 | VideoTranscodingPayload | 16 | VideoTranscodingPayload |
@@ -110,7 +110,7 @@ async function handleHLSJob (job: Job, payload: HLSTranscodingPayload, video: MV | |||
110 | 110 | ||
111 | async function handleNewWebTorrentResolutionJob ( | 111 | async function handleNewWebTorrentResolutionJob ( |
112 | job: Job, | 112 | job: Job, |
113 | payload: NewResolutionTranscodingPayload, | 113 | payload: NewWebTorrentResolutionTranscodingPayload, |
114 | video: MVideoFullLight, | 114 | video: MVideoFullLight, |
115 | user: MUserId | 115 | user: MUserId |
116 | ) { | 116 | ) { |
@@ -217,9 +217,12 @@ async function onVideoFirstWebTorrentTranscoding ( | |||
217 | async function onNewWebTorrentFileResolution ( | 217 | async function onNewWebTorrentFileResolution ( |
218 | video: MVideo, | 218 | video: MVideo, |
219 | user: MUserId, | 219 | user: MUserId, |
220 | payload: NewResolutionTranscodingPayload | MergeAudioTranscodingPayload | 220 | payload: NewWebTorrentResolutionTranscodingPayload | MergeAudioTranscodingPayload |
221 | ) { | 221 | ) { |
222 | await createHlsJobIfEnabled(user, { hasAudio: true, copyCodecs: true, isMaxQuality: false, ...payload }) | 222 | if (payload.createHLSIfNeeded) { |
223 | await createHlsJobIfEnabled(user, { hasAudio: true, copyCodecs: true, isMaxQuality: false, ...payload }) | ||
224 | } | ||
225 | |||
223 | await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode') | 226 | await VideoJobInfoModel.decrease(video.uuid, 'pendingTranscode') |
224 | 227 | ||
225 | await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo) | 228 | await retryTransactionWrapper(moveToNextState, video, payload.isNewVideo) |
@@ -282,6 +285,7 @@ async function createLowerResolutionsJobs (options: { | |||
282 | resolution, | 285 | resolution, |
283 | isPortraitMode, | 286 | isPortraitMode, |
284 | hasAudio, | 287 | hasAudio, |
288 | createHLSIfNeeded: true, | ||
285 | isNewVideo | 289 | isNewVideo |
286 | } | 290 | } |
287 | 291 | ||
diff --git a/server/lib/video.ts b/server/lib/video.ts index e5af028ea..2690f953d 100644 --- a/server/lib/video.ts +++ b/server/lib/video.ts | |||
@@ -89,6 +89,7 @@ async function addOptimizeOrMergeAudioJob (video: MVideoUUID, videoFile: MVideoF | |||
89 | type: 'merge-audio-to-webtorrent', | 89 | type: 'merge-audio-to-webtorrent', |
90 | resolution: DEFAULT_AUDIO_RESOLUTION, | 90 | resolution: DEFAULT_AUDIO_RESOLUTION, |
91 | videoUUID: video.uuid, | 91 | videoUUID: video.uuid, |
92 | createHLSIfNeeded: true, | ||
92 | isNewVideo: true | 93 | isNewVideo: true |
93 | } | 94 | } |
94 | } else { | 95 | } else { |
diff --git a/server/tests/api/videos/video-create-transcoding.ts b/server/tests/api/videos/video-create-transcoding.ts index 62a6bab0d..dcdbd9c6e 100644 --- a/server/tests/api/videos/video-create-transcoding.ts +++ b/server/tests/api/videos/video-create-transcoding.ts | |||
@@ -25,7 +25,11 @@ async function checkFilesInObjectStorage (video: VideoDetails) { | |||
25 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) | 25 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) |
26 | } | 26 | } |
27 | 27 | ||
28 | for (const file of video.streamingPlaylists[0].files) { | 28 | const streamingPlaylistFiles = video.streamingPlaylists.length === 0 |
29 | ? [] | ||
30 | : video.streamingPlaylists[0].files | ||
31 | |||
32 | for (const file of streamingPlaylistFiles) { | ||
29 | expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl()) | 33 | expectStartWith(file.fileUrl, ObjectStorageCommand.getPlaylistBaseUrl()) |
30 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) | 34 | await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) |
31 | } | 35 | } |
@@ -127,6 +131,25 @@ function runTests (objectStorage: boolean) { | |||
127 | } | 131 | } |
128 | }) | 132 | }) |
129 | 133 | ||
134 | it('Should only generate WebTorrent', async function () { | ||
135 | this.timeout(60000) | ||
136 | |||
137 | await servers[0].videos.removeHLSFiles({ videoId: videoUUID }) | ||
138 | await waitJobs(servers) | ||
139 | |||
140 | await servers[0].videos.runTranscoding({ videoId: videoUUID, transcodingType: 'webtorrent' }) | ||
141 | await waitJobs(servers) | ||
142 | |||
143 | for (const server of servers) { | ||
144 | const videoDetails = await server.videos.get({ id: videoUUID }) | ||
145 | |||
146 | expect(videoDetails.files).to.have.lengthOf(5) | ||
147 | expect(videoDetails.streamingPlaylists).to.have.lengthOf(0) | ||
148 | |||
149 | if (objectStorage) await checkFilesInObjectStorage(videoDetails) | ||
150 | } | ||
151 | }) | ||
152 | |||
130 | it('Should not have updated published at attributes', async function () { | 153 | it('Should not have updated published at attributes', async function () { |
131 | const video = await servers[0].videos.get({ id: videoUUID }) | 154 | const video = await servers[0].videos.get({ id: videoUUID }) |
132 | 155 | ||