]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/tests/api/videos/video-transcoder.ts
c95053a294bb8e1d4970c0c5ba58e33577498988
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-transcoder.ts
1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3 import 'mocha'
4 import * as chai from 'chai'
5 import { FfprobeData } from 'fluent-ffmpeg'
6 import { omit } from 'lodash'
7 import { join } from 'path'
8 import { Job } from '@shared/models'
9 import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants'
10 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
11 import {
12 buildAbsoluteFixturePath,
13 buildServerDirectory,
14 cleanupTests,
15 doubleFollow,
16 flushAndRunMultipleServers,
17 generateHighBitrateVideo,
18 generateVideoWithFramerate,
19 getMyVideos,
20 getServerFileSize,
21 getVideo,
22 getVideoFileMetadataUrl,
23 getVideosList,
24 makeGetRequest,
25 ServerInfo,
26 setAccessTokensToServers,
27 updateCustomSubConfig,
28 uploadVideo,
29 uploadVideoAndGetId,
30 waitJobs,
31 webtorrentAdd
32 } from '../../../../shared/extra-utils'
33 import { getMaxBitrate, VideoDetails, VideoResolution, VideoState } from '../../../../shared/models/videos'
34 import {
35 canDoQuickTranscode,
36 getAudioStream,
37 getMetadataFromFile,
38 getVideoFileBitrate,
39 getVideoFileFPS,
40 getVideoFileResolution
41 } from '../../../helpers/ffprobe-utils'
42
43 const expect = chai.expect
44
45 function updateConfigForTranscoding (server: ServerInfo) {
46 return updateCustomSubConfig(server.url, server.accessToken, {
47 transcoding: {
48 enabled: true,
49 allowAdditionalExtensions: true,
50 allowAudioFiles: true,
51 hls: { enabled: true },
52 webtorrent: { enabled: true },
53 resolutions: {
54 '0p': false,
55 '240p': true,
56 '360p': true,
57 '480p': true,
58 '720p': true,
59 '1080p': true,
60 '1440p': true,
61 '2160p': true
62 }
63 }
64 })
65 }
66
67 describe('Test video transcoding', function () {
68 let servers: ServerInfo[] = []
69 let video4k: string
70
71 before(async function () {
72 this.timeout(30_000)
73
74 // Run servers
75 servers = await flushAndRunMultipleServers(2)
76
77 await setAccessTokensToServers(servers)
78
79 await doubleFollow(servers[0], servers[1])
80
81 await updateConfigForTranscoding(servers[1])
82 })
83
84 describe('Basic transcoding (or not)', function () {
85
86 it('Should not transcode video on server 1', async function () {
87 this.timeout(60_000)
88
89 const videoAttributes = {
90 name: 'my super name for server 1',
91 description: 'my super description for server 1',
92 fixture: 'video_short.webm'
93 }
94 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
95
96 await waitJobs(servers)
97
98 for (const server of servers) {
99 const res = await getVideosList(server.url)
100 const video = res.body.data[0]
101
102 const res2 = await getVideo(server.url, video.id)
103 const videoDetails = res2.body
104 expect(videoDetails.files).to.have.lengthOf(1)
105
106 const magnetUri = videoDetails.files[0].magnetUri
107 expect(magnetUri).to.match(/\.webm/)
108
109 const torrent = await webtorrentAdd(magnetUri, true)
110 expect(torrent.files).to.be.an('array')
111 expect(torrent.files.length).to.equal(1)
112 expect(torrent.files[0].path).match(/\.webm$/)
113 }
114 })
115
116 it('Should transcode video on server 2', async function () {
117 this.timeout(120_000)
118
119 const videoAttributes = {
120 name: 'my super name for server 2',
121 description: 'my super description for server 2',
122 fixture: 'video_short.webm'
123 }
124 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
125
126 await waitJobs(servers)
127
128 for (const server of servers) {
129 const res = await getVideosList(server.url)
130
131 const video = res.body.data.find(v => v.name === videoAttributes.name)
132 const res2 = await getVideo(server.url, video.id)
133 const videoDetails = res2.body
134
135 expect(videoDetails.files).to.have.lengthOf(4)
136
137 const magnetUri = videoDetails.files[0].magnetUri
138 expect(magnetUri).to.match(/\.mp4/)
139
140 const torrent = await webtorrentAdd(magnetUri, true)
141 expect(torrent.files).to.be.an('array')
142 expect(torrent.files.length).to.equal(1)
143 expect(torrent.files[0].path).match(/\.mp4$/)
144 }
145 })
146
147 it('Should wait for transcoding before publishing the video', async function () {
148 this.timeout(160_000)
149
150 {
151 // Upload the video, but wait transcoding
152 const videoAttributes = {
153 name: 'waiting video',
154 fixture: 'video_short1.webm',
155 waitTranscoding: true
156 }
157 const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
158 const videoId = resVideo.body.video.uuid
159
160 // Should be in transcode state
161 const { body } = await getVideo(servers[1].url, videoId)
162 expect(body.name).to.equal('waiting video')
163 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
164 expect(body.state.label).to.equal('To transcode')
165 expect(body.waitTranscoding).to.be.true
166
167 // Should have my video
168 const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10)
169 const videoToFindInMine = resMyVideos.body.data.find(v => v.name === videoAttributes.name)
170 expect(videoToFindInMine).not.to.be.undefined
171 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
172 expect(videoToFindInMine.state.label).to.equal('To transcode')
173 expect(videoToFindInMine.waitTranscoding).to.be.true
174
175 // Should not list this video
176 const resVideos = await getVideosList(servers[1].url)
177 const videoToFindInList = resVideos.body.data.find(v => v.name === videoAttributes.name)
178 expect(videoToFindInList).to.be.undefined
179
180 // Server 1 should not have the video yet
181 await getVideo(servers[0].url, videoId, HttpStatusCode.NOT_FOUND_404)
182 }
183
184 await waitJobs(servers)
185
186 for (const server of servers) {
187 const res = await getVideosList(server.url)
188 const videoToFind = res.body.data.find(v => v.name === 'waiting video')
189 expect(videoToFind).not.to.be.undefined
190
191 const res2 = await getVideo(server.url, videoToFind.id)
192 const videoDetails: VideoDetails = res2.body
193
194 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
195 expect(videoDetails.state.label).to.equal('Published')
196 expect(videoDetails.waitTranscoding).to.be.true
197 }
198 })
199
200 it('Should accept and transcode additional extensions', async function () {
201 this.timeout(300_000)
202
203 let tempFixturePath: string
204
205 {
206 tempFixturePath = await generateHighBitrateVideo()
207
208 const bitrate = await getVideoFileBitrate(tempFixturePath)
209 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
210 }
211
212 for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
213 const videoAttributes = {
214 name: fixture,
215 fixture
216 }
217
218 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
219
220 await waitJobs(servers)
221
222 for (const server of servers) {
223 const res = await getVideosList(server.url)
224
225 const video = res.body.data.find(v => v.name === videoAttributes.name)
226 const res2 = await getVideo(server.url, video.id)
227 const videoDetails = res2.body
228
229 expect(videoDetails.files).to.have.lengthOf(4)
230
231 const magnetUri = videoDetails.files[0].magnetUri
232 expect(magnetUri).to.contain('.mp4')
233 }
234 }
235 })
236
237 it('Should transcode a 4k video', async function () {
238 this.timeout(200_000)
239
240 const videoAttributes = {
241 name: '4k video',
242 fixture: 'video_short_4k.mp4'
243 }
244
245 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
246 video4k = resUpload.body.video.uuid
247
248 await waitJobs(servers)
249
250 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
251
252 for (const server of servers) {
253 const res = await getVideo(server.url, video4k)
254 const videoDetails: VideoDetails = res.body
255
256 expect(videoDetails.files).to.have.lengthOf(resolutions.length)
257
258 for (const r of resolutions) {
259 expect(videoDetails.files.find(f => f.resolution.id === r)).to.not.be.undefined
260 expect(videoDetails.streamingPlaylists[0].files.find(f => f.resolution.id === r)).to.not.be.undefined
261 }
262 }
263 })
264 })
265
266 describe('Audio transcoding', function () {
267
268 it('Should transcode high bit rate mp3 to proper bit rate', async function () {
269 this.timeout(60_000)
270
271 const videoAttributes = {
272 name: 'mp3_256k',
273 fixture: 'video_short_mp3_256k.mp4'
274 }
275 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
276
277 await waitJobs(servers)
278
279 for (const server of servers) {
280 const res = await getVideosList(server.url)
281
282 const video = res.body.data.find(v => v.name === videoAttributes.name)
283 const res2 = await getVideo(server.url, video.id)
284 const videoDetails: VideoDetails = res2.body
285
286 expect(videoDetails.files).to.have.lengthOf(4)
287
288 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
289 const probe = await getAudioStream(path)
290
291 if (probe.audioStream) {
292 expect(probe.audioStream['codec_name']).to.be.equal('aac')
293 expect(probe.audioStream['bit_rate']).to.be.at.most(384 * 8000)
294 } else {
295 this.fail('Could not retrieve the audio stream on ' + probe.absolutePath)
296 }
297 }
298 })
299
300 it('Should transcode video with no audio and have no audio itself', async function () {
301 this.timeout(60_000)
302
303 const videoAttributes = {
304 name: 'no_audio',
305 fixture: 'video_short_no_audio.mp4'
306 }
307 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
308
309 await waitJobs(servers)
310
311 for (const server of servers) {
312 const res = await getVideosList(server.url)
313
314 const video = res.body.data.find(v => v.name === videoAttributes.name)
315 const res2 = await getVideo(server.url, video.id)
316 const videoDetails: VideoDetails = res2.body
317
318 expect(videoDetails.files).to.have.lengthOf(4)
319 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
320 const probe = await getAudioStream(path)
321 expect(probe).to.not.have.property('audioStream')
322 }
323 })
324
325 it('Should leave the audio untouched, but properly transcode the video', async function () {
326 this.timeout(60_000)
327
328 const videoAttributes = {
329 name: 'untouched_audio',
330 fixture: 'video_short.mp4'
331 }
332 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
333
334 await waitJobs(servers)
335
336 for (const server of servers) {
337 const res = await getVideosList(server.url)
338
339 const video = res.body.data.find(v => v.name === videoAttributes.name)
340 const res2 = await getVideo(server.url, video.id)
341 const videoDetails: VideoDetails = res2.body
342
343 expect(videoDetails.files).to.have.lengthOf(4)
344
345 const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture)
346 const fixtureVideoProbe = await getAudioStream(fixturePath)
347 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
348
349 const videoProbe = await getAudioStream(path)
350
351 if (videoProbe.audioStream && fixtureVideoProbe.audioStream) {
352 const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ]
353 expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit))
354 } else {
355 this.fail('Could not retrieve the audio stream on ' + videoProbe.absolutePath)
356 }
357 }
358 })
359 })
360
361 describe('Audio upload', function () {
362
363 function runSuite (mode: 'legacy' | 'resumable') {
364
365 before(async function () {
366 await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
367 transcoding: {
368 hls: { enabled: true },
369 webtorrent: { enabled: true },
370 resolutions: {
371 '0p': false,
372 '240p': false,
373 '360p': false,
374 '480p': false,
375 '720p': false,
376 '1080p': false,
377 '1440p': false,
378 '2160p': false
379 }
380 }
381 })
382 })
383
384 it('Should merge an audio file with the preview file', async function () {
385 this.timeout(60_000)
386
387 const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
388 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode)
389
390 await waitJobs(servers)
391
392 for (const server of servers) {
393 const res = await getVideosList(server.url)
394
395 const video = res.body.data.find(v => v.name === 'audio_with_preview')
396 const res2 = await getVideo(server.url, video.id)
397 const videoDetails: VideoDetails = res2.body
398
399 expect(videoDetails.files).to.have.lengthOf(1)
400
401 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
402 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
403
404 const magnetUri = videoDetails.files[0].magnetUri
405 expect(magnetUri).to.contain('.mp4')
406 }
407 })
408
409 it('Should upload an audio file and choose a default background image', async function () {
410 this.timeout(60_000)
411
412 const videoAttributesArg = { name: 'audio_without_preview', fixture: 'sample.ogg' }
413 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode)
414
415 await waitJobs(servers)
416
417 for (const server of servers) {
418 const res = await getVideosList(server.url)
419
420 const video = res.body.data.find(v => v.name === 'audio_without_preview')
421 const res2 = await getVideo(server.url, video.id)
422 const videoDetails = res2.body
423
424 expect(videoDetails.files).to.have.lengthOf(1)
425
426 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
427 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
428
429 const magnetUri = videoDetails.files[0].magnetUri
430 expect(magnetUri).to.contain('.mp4')
431 }
432 })
433
434 it('Should upload an audio file and create an audio version only', async function () {
435 this.timeout(60_000)
436
437 await updateCustomSubConfig(servers[1].url, servers[1].accessToken, {
438 transcoding: {
439 hls: { enabled: true },
440 webtorrent: { enabled: true },
441 resolutions: {
442 '0p': true,
443 '240p': false,
444 '360p': false
445 }
446 }
447 })
448
449 const videoAttributesArg = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
450 const resVideo = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributesArg, HttpStatusCode.OK_200, mode)
451
452 await waitJobs(servers)
453
454 for (const server of servers) {
455 const res2 = await getVideo(server.url, resVideo.body.video.id)
456 const videoDetails: VideoDetails = res2.body
457
458 for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
459 expect(files).to.have.lengthOf(2)
460 expect(files.find(f => f.resolution.id === 0)).to.not.be.undefined
461 }
462 }
463
464 await updateConfigForTranscoding(servers[1])
465 })
466 }
467
468 describe('Legacy upload', function () {
469 runSuite('legacy')
470 })
471
472 describe('Resumable upload', function () {
473 runSuite('resumable')
474 })
475 })
476
477 describe('Framerate', function () {
478
479 it('Should transcode a 60 FPS video', async function () {
480 this.timeout(60_000)
481
482 const videoAttributes = {
483 name: 'my super 30fps name for server 2',
484 description: 'my super 30fps description for server 2',
485 fixture: '60fps_720p_small.mp4'
486 }
487 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
488
489 await waitJobs(servers)
490
491 for (const server of servers) {
492 const res = await getVideosList(server.url)
493
494 const video = res.body.data.find(v => v.name === videoAttributes.name)
495 const res2 = await getVideo(server.url, video.id)
496 const videoDetails: VideoDetails = res2.body
497
498 expect(videoDetails.files).to.have.lengthOf(4)
499 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
500 expect(videoDetails.files[1].fps).to.be.below(31)
501 expect(videoDetails.files[2].fps).to.be.below(31)
502 expect(videoDetails.files[3].fps).to.be.below(31)
503
504 for (const resolution of [ '240', '360', '480' ]) {
505 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
506 const fps = await getVideoFileFPS(path)
507
508 expect(fps).to.be.below(31)
509 }
510
511 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
512 const fps = await getVideoFileFPS(path)
513
514 expect(fps).to.be.above(58).and.below(62)
515 }
516 })
517
518 it('Should downscale to the closest divisor standard framerate', async function () {
519 this.timeout(200_000)
520
521 let tempFixturePath: string
522
523 {
524 tempFixturePath = await generateVideoWithFramerate(59)
525
526 const fps = await getVideoFileFPS(tempFixturePath)
527 expect(fps).to.be.equal(59)
528 }
529
530 const videoAttributes = {
531 name: '59fps video',
532 description: '59fps video',
533 fixture: tempFixturePath
534 }
535
536 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
537
538 await waitJobs(servers)
539
540 for (const server of servers) {
541 const res = await getVideosList(server.url)
542
543 const video = res.body.data.find(v => v.name === videoAttributes.name)
544
545 {
546 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4'))
547 const fps = await getVideoFileFPS(path)
548 expect(fps).to.be.equal(25)
549 }
550
551 {
552 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4'))
553 const fps = await getVideoFileFPS(path)
554 expect(fps).to.be.equal(59)
555 }
556 }
557 })
558 })
559
560 describe('Bitrate control', function () {
561 it('Should respect maximum bitrate values', async function () {
562 this.timeout(160_000)
563
564 let tempFixturePath: string
565
566 {
567 tempFixturePath = await generateHighBitrateVideo()
568
569 const bitrate = await getVideoFileBitrate(tempFixturePath)
570 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
571 }
572
573 const videoAttributes = {
574 name: 'high bitrate video',
575 description: 'high bitrate video',
576 fixture: tempFixturePath
577 }
578
579 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
580
581 await waitJobs(servers)
582
583 for (const server of servers) {
584 const res = await getVideosList(server.url)
585
586 const video = res.body.data.find(v => v.name === videoAttributes.name)
587
588 for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
589 const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4'))
590
591 const bitrate = await getVideoFileBitrate(path)
592 const fps = await getVideoFileFPS(path)
593 const resolution2 = await getVideoFileResolution(path)
594
595 expect(resolution2.videoFileResolution.toString()).to.equal(resolution)
596 expect(bitrate).to.be.below(getMaxBitrate(resolution2.videoFileResolution, fps, VIDEO_TRANSCODING_FPS))
597 }
598 }
599 })
600
601 it('Should not transcode to an higher bitrate than the original file', async function () {
602 this.timeout(160_000)
603
604 const config = {
605 transcoding: {
606 enabled: true,
607 resolutions: {
608 '240p': true,
609 '360p': true,
610 '480p': true,
611 '720p': true,
612 '1080p': true,
613 '1440p': true,
614 '2160p': true
615 },
616 webtorrent: { enabled: true },
617 hls: { enabled: true }
618 }
619 }
620 await updateCustomSubConfig(servers[1].url, servers[1].accessToken, config)
621
622 const videoAttributes = {
623 name: 'low bitrate',
624 fixture: 'low-bitrate.mp4'
625 }
626
627 const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
628 const videoUUID = resUpload.body.video.uuid
629
630 await waitJobs(servers)
631
632 const resolutions = [ 240, 360, 480, 720, 1080 ]
633 for (const r of resolutions) {
634 const path = `videos/${videoUUID}-${r}.mp4`
635 const size = await getServerFileSize(servers[1], path)
636 expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
637 }
638 })
639 })
640
641 describe('FFprobe', function () {
642
643 it('Should provide valid ffprobe data', async function () {
644 this.timeout(160_000)
645
646 const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'ffprobe data' })).uuid
647 await waitJobs(servers)
648
649 {
650 const path = buildServerDirectory(servers[1], join('videos', videoUUID + '-240.mp4'))
651 const metadata = await getMetadataFromFile(path)
652
653 // expected format properties
654 for (const p of [
655 'tags.encoder',
656 'format_long_name',
657 'size',
658 'bit_rate'
659 ]) {
660 expect(metadata.format).to.have.nested.property(p)
661 }
662
663 // expected stream properties
664 for (const p of [
665 'codec_long_name',
666 'profile',
667 'width',
668 'height',
669 'display_aspect_ratio',
670 'avg_frame_rate',
671 'pix_fmt'
672 ]) {
673 expect(metadata.streams[0]).to.have.nested.property(p)
674 }
675
676 expect(metadata).to.not.have.nested.property('format.filename')
677 }
678
679 for (const server of servers) {
680 const res2 = await getVideo(server.url, videoUUID)
681 const videoDetails: VideoDetails = res2.body
682
683 const videoFiles = videoDetails.files
684 .concat(videoDetails.streamingPlaylists[0].files)
685 expect(videoFiles).to.have.lengthOf(8)
686
687 for (const file of videoFiles) {
688 expect(file.metadata).to.be.undefined
689 expect(file.metadataUrl).to.exist
690 expect(file.metadataUrl).to.contain(servers[1].url)
691 expect(file.metadataUrl).to.contain(videoUUID)
692
693 const res3 = await getVideoFileMetadataUrl(file.metadataUrl)
694 const metadata: FfprobeData = res3.body
695 expect(metadata).to.have.nested.property('format.size')
696 }
697 }
698 })
699
700 it('Should correctly detect if quick transcode is possible', async function () {
701 this.timeout(10_000)
702
703 expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.mp4'))).to.be.true
704 expect(await canDoQuickTranscode(buildAbsoluteFixturePath('video_short.webm'))).to.be.false
705 })
706 })
707
708 describe('Transcoding job queue', function () {
709
710 it('Should have the appropriate priorities for transcoding jobs', async function () {
711 const body = await servers[1].jobsCommand.getJobsList({
712 start: 0,
713 count: 100,
714 sort: '-createdAt',
715 jobType: 'video-transcoding'
716 })
717
718 const jobs = body.data
719 const transcodingJobs = jobs.filter(j => j.data.videoUUID === video4k)
720
721 expect(transcodingJobs).to.have.lengthOf(14)
722
723 const hlsJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-hls')
724 const webtorrentJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-webtorrent')
725 const optimizeJobs = transcodingJobs.filter(j => j.data.type === 'optimize-to-webtorrent')
726
727 expect(hlsJobs).to.have.lengthOf(7)
728 expect(webtorrentJobs).to.have.lengthOf(6)
729 expect(optimizeJobs).to.have.lengthOf(1)
730
731 for (const j of optimizeJobs.concat(hlsJobs.concat(webtorrentJobs))) {
732 expect(j.priority).to.be.greaterThan(100)
733 expect(j.priority).to.be.lessThan(150)
734 }
735 })
736 })
737
738 after(async function () {
739 await cleanupTests(servers)
740 })
741 })