diff options
-rwxr-xr-x | scripts/create-transcoding-job.ts | 2 | ||||
-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 | ||||
-rw-r--r-- | shared/models/server/job.model.ts | 6 |
6 files changed, 42 insertions, 9 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index 95e1e66cf..c4b376431 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -77,6 +77,8 @@ async function run () { | |||
77 | type: 'new-resolution-to-webtorrent', | 77 | type: 'new-resolution-to-webtorrent', |
78 | videoUUID: video.uuid, | 78 | videoUUID: video.uuid, |
79 | 79 | ||
80 | createHLSIfNeeded: true, | ||
81 | |||
80 | // FIXME: check the file has audio | 82 | // FIXME: check the file has audio |
81 | hasAudio: true, | 83 | hasAudio: true, |
82 | 84 | ||
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 | ||
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts index 8a69d11fa..1519d1c3e 100644 --- a/shared/models/server/job.model.ts +++ b/shared/models/server/job.model.ts | |||
@@ -113,11 +113,12 @@ export interface HLSTranscodingPayload extends BaseTranscodingPayload { | |||
113 | isMaxQuality: boolean | 113 | isMaxQuality: boolean |
114 | } | 114 | } |
115 | 115 | ||
116 | export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload { | 116 | export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload { |
117 | type: 'new-resolution-to-webtorrent' | 117 | type: 'new-resolution-to-webtorrent' |
118 | resolution: VideoResolution | 118 | resolution: VideoResolution |
119 | 119 | ||
120 | hasAudio: boolean | 120 | hasAudio: boolean |
121 | createHLSIfNeeded: boolean | ||
121 | 122 | ||
122 | isPortraitMode?: boolean | 123 | isPortraitMode?: boolean |
123 | } | 124 | } |
@@ -125,6 +126,7 @@ export interface NewResolutionTranscodingPayload extends BaseTranscodingPayload | |||
125 | export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { | 126 | export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { |
126 | type: 'merge-audio-to-webtorrent' | 127 | type: 'merge-audio-to-webtorrent' |
127 | resolution: VideoResolution | 128 | resolution: VideoResolution |
129 | createHLSIfNeeded: true | ||
128 | } | 130 | } |
129 | 131 | ||
130 | export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | 132 | export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { |
@@ -133,7 +135,7 @@ export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | |||
133 | 135 | ||
134 | export type VideoTranscodingPayload = | 136 | export type VideoTranscodingPayload = |
135 | HLSTranscodingPayload | 137 | HLSTranscodingPayload |
136 | | NewResolutionTranscodingPayload | 138 | | NewWebTorrentResolutionTranscodingPayload |
137 | | OptimizeTranscodingPayload | 139 | | OptimizeTranscodingPayload |
138 | | MergeAudioTranscodingPayload | 140 | | MergeAudioTranscodingPayload |
139 | 141 | ||