From 8dd754c76735417305c4b68e2ada6f623e9d7650 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Fri, 5 Nov 2021 10:23:02 +0100 Subject: Added 144p encoding (#4492) * Added 144p encoding Implements https://github.com/Chocobozzz/PeerTube/issues/4428 * Fixed typo in core-utils * Increased BitPerPixel for 144p * Disabled 144p by default in test.yaml * Another try at fixing tests * Fixed test in video-transcoder (api-3) * Fixed test in video-imports (api-4) * Fixed test in live-constraints (api-2) * Tried to fix tests in api-3 again * Revert "Tried to fix tests in api-3 again" This reverts commit 266e1143fa37f333d149c2c2791c7bd33621ac14. * Fixed test in config.ts (api-2) * Try to fix test in video-hls.ts (api-3) * Fixed test in video-transcoder.ts (api-3) * Fix tests Co-authored-by: Chocobozzz --- server/tests/api/check-params/config.ts | 2 ++ server/tests/api/live/live-constraints.ts | 2 +- server/tests/api/live/live.ts | 1 + server/tests/api/object-storage/live.ts | 2 +- server/tests/api/object-storage/video-imports.ts | 4 ++-- server/tests/api/server/config.ts | 6 +++++ server/tests/api/server/stats.ts | 1 + server/tests/api/videos/audio-only.ts | 1 + server/tests/api/videos/video-hls.ts | 1 + server/tests/api/videos/video-imports.ts | 1 + server/tests/api/videos/video-transcoder.ts | 29 ++++++++++++++---------- 11 files changed, 34 insertions(+), 16 deletions(-) (limited to 'server/tests/api') diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 273b1f718..d0cd7722b 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts @@ -93,6 +93,7 @@ describe('Test config API validators', function () { profile: 'vod_profile', resolutions: { '0p': false, + '144p': false, '240p': false, '360p': true, '480p': true, @@ -121,6 +122,7 @@ describe('Test config API validators', function () { threads: 4, profile: 'live_profile', resolutions: { + '144p': true, '240p': true, '360p': true, '480p': true, diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts index 4acde3cc5..6a6a11796 100644 --- a/server/tests/api/live/live-constraints.ts +++ b/server/tests/api/live/live-constraints.ts @@ -168,7 +168,7 @@ describe('Test live constraints', function () { await waitUntilLivePublishedOnAllServers(userVideoLiveoId) await waitJobs(servers) - await checkSaveReplay(userVideoLiveoId, [ 720, 480, 360, 240 ]) + await checkSaveReplay(userVideoLiveoId, [ 720, 480, 360, 240, 144 ]) }) after(async function () { diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 0b405dd94..619602d0b 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts @@ -421,6 +421,7 @@ describe('Test live', function () { transcoding: { enabled: true, resolutions: { + '144p': resolutions.includes(144), '240p': resolutions.includes(240), '360p': resolutions.includes(360), '480p': resolutions.includes(480), diff --git a/server/tests/api/object-storage/live.ts b/server/tests/api/object-storage/live.ts index d3e6777f2..3726a717b 100644 --- a/server/tests/api/object-storage/live.ts +++ b/server/tests/api/object-storage/live.ts @@ -123,7 +123,7 @@ describe('Object storage for lives', function () { expect(video.streamingPlaylists).to.have.lengthOf(1) const files = video.streamingPlaylists[0].files - expect(files).to.have.lengthOf(4) + expect(files).to.have.lengthOf(5) await checkFiles(files) } diff --git a/server/tests/api/object-storage/video-imports.ts b/server/tests/api/object-storage/video-imports.ts index efc01f550..363fe3b5b 100644 --- a/server/tests/api/object-storage/video-imports.ts +++ b/server/tests/api/object-storage/video-imports.ts @@ -88,9 +88,9 @@ describe('Object storage for video import', function () { const video = await server.videos.get({ id: uuid }) - expect(video.files).to.have.lengthOf(4) + expect(video.files).to.have.lengthOf(5) expect(video.streamingPlaylists).to.have.lengthOf(1) - expect(video.streamingPlaylists[0].files).to.have.lengthOf(4) + expect(video.streamingPlaylists[0].files).to.have.lengthOf(5) for (const file of video.files) { expectStartWith(file.fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl()) diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index 8d5b3ac7f..ea524723c 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts @@ -66,6 +66,7 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { expect(data.transcoding.threads).to.equal(2) expect(data.transcoding.concurrency).to.equal(2) expect(data.transcoding.profile).to.equal('default') + expect(data.transcoding.resolutions['144p']).to.be.false expect(data.transcoding.resolutions['240p']).to.be.true expect(data.transcoding.resolutions['360p']).to.be.true expect(data.transcoding.resolutions['480p']).to.be.true @@ -84,6 +85,7 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { expect(data.live.transcoding.enabled).to.be.false expect(data.live.transcoding.threads).to.equal(2) expect(data.live.transcoding.profile).to.equal('default') + expect(data.live.transcoding.resolutions['144p']).to.be.false expect(data.live.transcoding.resolutions['240p']).to.be.false expect(data.live.transcoding.resolutions['360p']).to.be.false expect(data.live.transcoding.resolutions['480p']).to.be.false @@ -163,6 +165,7 @@ function checkUpdatedConfig (data: CustomConfig) { expect(data.transcoding.allowAdditionalExtensions).to.be.true expect(data.transcoding.allowAudioFiles).to.be.true expect(data.transcoding.profile).to.equal('vod_profile') + expect(data.transcoding.resolutions['144p']).to.be.false expect(data.transcoding.resolutions['240p']).to.be.false expect(data.transcoding.resolutions['360p']).to.be.true expect(data.transcoding.resolutions['480p']).to.be.true @@ -180,6 +183,7 @@ function checkUpdatedConfig (data: CustomConfig) { expect(data.live.transcoding.enabled).to.be.true expect(data.live.transcoding.threads).to.equal(4) expect(data.live.transcoding.profile).to.equal('live_profile') + expect(data.live.transcoding.resolutions['144p']).to.be.true expect(data.live.transcoding.resolutions['240p']).to.be.true expect(data.live.transcoding.resolutions['360p']).to.be.true expect(data.live.transcoding.resolutions['480p']).to.be.true @@ -281,6 +285,7 @@ const newCustomConfig: CustomConfig = { profile: 'vod_profile', resolutions: { '0p': false, + '144p': false, '240p': false, '360p': true, '480p': true, @@ -307,6 +312,7 @@ const newCustomConfig: CustomConfig = { threads: 4, profile: 'live_profile', resolutions: { + '144p': true, '240p': true, '360p': true, '480p': true, diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index 5ec771429..efc80463c 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts @@ -198,6 +198,7 @@ describe('Test stats (excluding redundancy)', function () { }, resolutions: { '0p': false, + '144p': false, '240p': false, '360p': false, '480p': false, diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts index 7fac6e738..f4b635bd5 100644 --- a/server/tests/api/videos/audio-only.ts +++ b/server/tests/api/videos/audio-only.ts @@ -21,6 +21,7 @@ describe('Test audio only video transcoding', function () { enabled: true, resolutions: { '0p': true, + '144p': false, '240p': true, '360p': false, '480p': false, diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 91124725f..a18c3d672 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -243,6 +243,7 @@ describe('Test HLS videos', function () { enabled: true, allowAudioFiles: true, resolutions: { + '144p': false, '240p': true, '360p': true, '480p': true, diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index bb1627a27..987f34e97 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts @@ -300,6 +300,7 @@ describe('Test video imports', function () { transcoding: { enabled: true, resolutions: { + '144p': true, '240p': true, '360p': false, '480p': false, diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 21609fd82..b3226dbf7 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -40,6 +40,7 @@ function updateConfigForTranscoding (server: PeerTubeServer) { webtorrent: { enabled: true }, resolutions: { '0p': false, + '144p': true, '240p': true, '360p': true, '480p': true, @@ -119,7 +120,7 @@ describe('Test video transcoding', function () { const video = data.find(v => v.name === attributes.name) const videoDetails = await server.videos.get({ id: video.id }) - expect(videoDetails.files).to.have.lengthOf(4) + expect(videoDetails.files).to.have.lengthOf(5) const magnetUri = videoDetails.files[0].magnetUri expect(magnetUri).to.match(/\.mp4/) @@ -205,7 +206,7 @@ describe('Test video transcoding', function () { const video = data.find(v => v.name === attributes.name) const videoDetails = await server.videos.get({ id: video.id }) - expect(videoDetails.files).to.have.lengthOf(4) + expect(videoDetails.files).to.have.lengthOf(5) const magnetUri = videoDetails.files[0].magnetUri expect(magnetUri).to.contain('.mp4') @@ -226,7 +227,7 @@ describe('Test video transcoding', function () { await waitJobs(servers) - const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ] + const resolutions = [ 144, 240, 360, 480, 720, 1080, 1440, 2160 ] for (const server of servers) { const videoDetails = await server.videos.get({ id: video4k }) @@ -259,7 +260,7 @@ describe('Test video transcoding', function () { const video = data.find(v => v.name === attributes.name) const videoDetails = await server.videos.get({ id: video.id }) - expect(videoDetails.files).to.have.lengthOf(4) + expect(videoDetails.files).to.have.lengthOf(5) const file = videoDetails.files.find(f => f.resolution.id === 240) const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl) @@ -316,7 +317,7 @@ describe('Test video transcoding', function () { const video = data.find(v => v.name === attributes.name) const videoDetails = await server.videos.get({ id: video.id }) - expect(videoDetails.files).to.have.lengthOf(4) + expect(videoDetails.files).to.have.lengthOf(5) const fixturePath = buildAbsoluteFixturePath(attributes.fixture) const fixtureVideoProbe = await getAudioStream(fixturePath) @@ -348,6 +349,7 @@ describe('Test video transcoding', function () { webtorrent: { enabled: true }, resolutions: { '0p': false, + '144p': false, '240p': false, '360p': false, '480p': false, @@ -419,6 +421,7 @@ describe('Test video transcoding', function () { webtorrent: { enabled: true }, resolutions: { '0p': true, + '144p': false, '240p': false, '360p': false } @@ -473,13 +476,14 @@ describe('Test video transcoding', function () { const video = data.find(v => v.name === attributes.name) const videoDetails = await server.videos.get({ id: video.id }) - expect(videoDetails.files).to.have.lengthOf(4) + expect(videoDetails.files).to.have.lengthOf(5) expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) expect(videoDetails.files[1].fps).to.be.below(31) expect(videoDetails.files[2].fps).to.be.below(31) expect(videoDetails.files[3].fps).to.be.below(31) + expect(videoDetails.files[4].fps).to.be.below(31) - for (const resolution of [ 240, 360, 480 ]) { + for (const resolution of [ 144, 240, 360, 480 ]) { const file = videoDetails.files.find(f => f.resolution.id === resolution) const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl) const fps = await getVideoFileFPS(path) @@ -586,6 +590,7 @@ describe('Test video transcoding', function () { transcoding: { enabled: true, resolutions: { + '144p': true, '240p': true, '360p': true, '480p': true, @@ -667,7 +672,7 @@ describe('Test video transcoding', function () { const videoFiles = videoDetails.files .concat(videoDetails.streamingPlaylists[0].files) - expect(videoFiles).to.have.lengthOf(8) + expect(videoFiles).to.have.lengthOf(10) for (const file of videoFiles) { expect(file.metadata).to.be.undefined @@ -695,21 +700,21 @@ describe('Test video transcoding', function () { const body = await servers[1].jobs.list({ start: 0, count: 100, - sort: '-createdAt', + sort: 'createdAt', jobType: 'video-transcoding' }) const jobs = body.data const transcodingJobs = jobs.filter(j => j.data.videoUUID === video4k) - expect(transcodingJobs).to.have.lengthOf(14) + expect(transcodingJobs).to.have.lengthOf(16) 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(hlsJobs).to.have.lengthOf(8) + expect(webtorrentJobs).to.have.lengthOf(7) expect(optimizeJobs).to.have.lengthOf(1) for (const j of optimizeJobs.concat(hlsJobs.concat(webtorrentJobs))) { -- cgit v1.2.3