From 84cae54e7a2595bea0c3ea106a4d111fd11a4ec6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Aug 2022 10:36:19 +0200 Subject: Add option to not transcode original resolution --- server/tests/api/transcoding/transcoder.ts | 80 +++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) (limited to 'server/tests/api/transcoding/transcoder.ts') diff --git a/server/tests/api/transcoding/transcoder.ts b/server/tests/api/transcoding/transcoder.ts index 245c4c012..48a20e1d5 100644 --- a/server/tests/api/transcoding/transcoder.ts +++ b/server/tests/api/transcoding/transcoder.ts @@ -7,11 +7,11 @@ import { canDoQuickTranscode } from '@server/helpers/ffmpeg' import { generateHighBitrateVideo, generateVideoWithFramerate, getAllFiles } from '@server/tests/shared' import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils' import { - getAudioStream, buildFileMetadata, + getAudioStream, getVideoStreamBitrate, - getVideoStreamFPS, getVideoStreamDimensionsInfo, + getVideoStreamFPS, hasAudioStream } from '@shared/extra-utils' import { HttpStatusCode, VideoState } from '@shared/models' @@ -727,6 +727,82 @@ describe('Test video transcoding', function () { }) }) + describe('Bounded transcoding', function () { + + it('Should not generate an upper resolution than original file', async function () { + this.timeout(120_000) + + await servers[0].config.updateExistingSubConfig({ + newConfig: { + transcoding: { + enabled: true, + hls: { enabled: true }, + webtorrent: { enabled: true }, + resolutions: { + '0p': false, + '144p': false, + '240p': true, + '360p': false, + '480p': true, + '720p': false, + '1080p': false, + '1440p': false, + '2160p': false + }, + alwaysTranscodeOriginalResolution: false + } + } + }) + + const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' }) + await waitJobs(servers) + + const video = await servers[0].videos.get({ id: uuid }) + const hlsFiles = video.streamingPlaylists[0].files + + expect(video.files).to.have.lengthOf(2) + expect(hlsFiles).to.have.lengthOf(2) + + // eslint-disable-next-line @typescript-eslint/require-array-sort-compare + const resolutions = getAllFiles(video).map(f => f.resolution.id).sort() + expect(resolutions).to.deep.equal([ 240, 240, 480, 480 ]) + }) + + it('Should only keep the original resolution if all resolutions are disabled', async function () { + this.timeout(120_000) + + await servers[0].config.updateExistingSubConfig({ + newConfig: { + transcoding: { + resolutions: { + '0p': false, + '144p': false, + '240p': false, + '360p': false, + '480p': false, + '720p': false, + '1080p': false, + '1440p': false, + '2160p': false + } + } + } + }) + + const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' }) + await waitJobs(servers) + + const video = await servers[0].videos.get({ id: uuid }) + const hlsFiles = video.streamingPlaylists[0].files + + expect(video.files).to.have.lengthOf(1) + expect(hlsFiles).to.have.lengthOf(1) + + expect(video.files[0].resolution.id).to.equal(720) + expect(hlsFiles[0].resolution.id).to.equal(720) + }) + }) + after(async function () { await cleanupTests(servers) }) -- cgit v1.2.3