+ it('Should transcode a 4k video', async function () {
+ this.timeout(200_000)
+
+ const videoAttributes = {
+ name: '4k video',
+ fixture: 'video_short_4k.mp4'
+ }
+
+ const resUpload = await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
+ video4k = resUpload.body.video.uuid
+
+ await waitJobs(servers)
+
+ const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
+
+ for (const server of servers) {
+ const res = await getVideo(server.url, video4k)
+ const videoDetails: VideoDetails = res.body
+
+ expect(videoDetails.files).to.have.lengthOf(resolutions.length)
+
+ for (const r of resolutions) {
+ expect(videoDetails.files.find(f => f.resolution.id === r)).to.not.be.undefined
+ expect(videoDetails.streamingPlaylists[0].files.find(f => f.resolution.id === r)).to.not.be.undefined
+ }
+ }
+ })
+
+ it('Should have the appropriate priorities for transcoding jobs', async function () {
+ const res = await getJobsListPaginationAndSort({
+ url: servers[1].url,
+ accessToken: servers[1].accessToken,
+ start: 0,
+ count: 100,
+ sort: '-createdAt',
+ jobType: 'video-transcoding'
+ })
+
+ const jobs = res.body.data as Job[]
+
+ const transcodingJobs = jobs.filter(j => j.data.videoUUID === video4k)
+
+ expect(transcodingJobs).to.have.lengthOf(14)
+
+ const hlsJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-hls')
+ const webtorrentJobs = transcodingJobs.filter(j => j.data.type === 'new-resolution-to-webtorrent')
+ const optimizeJobs = transcodingJobs.filter(j => j.data.type === 'optimize-to-webtorrent')
+
+ expect(hlsJobs).to.have.lengthOf(7)
+ expect(webtorrentJobs).to.have.lengthOf(6)
+ expect(optimizeJobs).to.have.lengthOf(1)
+
+ for (const j of optimizeJobs) {
+ expect(j.priority).to.be.greaterThan(11)
+ expect(j.priority).to.be.lessThan(50)
+ }
+
+ for (const j of hlsJobs.concat(webtorrentJobs)) {
+ expect(j.priority).to.be.greaterThan(100)
+ expect(j.priority).to.be.lessThan(150)
+ }
+ })
+