1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Add option to not transcode original resolution

This commit is contained in:
Chocobozzz 2022-08-05 10:36:19 +02:00
parent 7e0f50d6e0
commit 84cae54e7a
No known key found for this signature in database
GPG key ID: 583A612D890159BE
26 changed files with 303 additions and 87 deletions

View file

@ -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)
})