ActivityPub-federated video streaming platform using P2P directly in your web browser
Refactor enableTranscoding command helpers
Chocobozzz74c8d5bf2d80
diff --git a/server/tests/api/check-params/runners.ts b/server/tests/api/check-params/runners.tsindex 7f9a0cd32f..0e5012da57 100644--- a/server/tests/api/check-params/runners.ts+++ b/server/tests/api/check-params/runners.ts@@ -65,7 +65,7 @@ describe('Test managing runners', function () {registrationToken = data[0].registrationTokenregistrationTokenId = data[0].id- await server.config.enableTranscoding(true, true)+ await server.config.enableTranscoding({ hls: true, webVideo: true })await server.config.enableStudio()await server.config.enableRemoteTranscoding()await server.config.enableRemoteStudio()@@ -451,7 +451,7 @@ describe('Test managing runners', function () {const { uuid } = await server.videos.quickUpload({ name: 'video studio' })videoStudioUUID = uuid- await server.config.enableTranscoding(true, true)+ await server.config.enableTranscoding({ hls: true, webVideo: true })await server.config.enableStudio()await server.videoStudio.createEditionTasks({diff --git a/server/tests/api/check-params/video-files.ts b/server/tests/api/check-params/video-files.tsindex 4d43ab6f82..01d6a912b5 100644--- a/server/tests/api/check-params/video-files.ts+++ b/server/tests/api/check-params/video-files.ts@@ -87,7 +87,7 @@ describe('Test videos files', function () {}{- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true }){const { uuid } = await servers[0].videos.quickUpload({ name: 'both 1' })@@ -108,7 +108,7 @@ describe('Test videos files', function () {await waitJobs(servers){- await servers[0].config.enableTranscoding(false, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: false })const { uuid } = await servers[0].videos.quickUpload({ name: 'hls' })hlsId = uuid}@@ -116,7 +116,7 @@ describe('Test videos files', function () {await waitJobs(servers){- await servers[0].config.enableTranscoding(false, true)+ await servers[0].config.enableTranscoding({ webVideo: true, hls: false })const { uuid } = await servers[0].videos.quickUpload({ name: 'web-video' })webVideoId = uuid}diff --git a/server/tests/api/live/live-fast-restream.ts b/server/tests/api/live/live-fast-restream.tsindex d7085a957c..1b7fddd8b4 100644--- a/server/tests/api/live/live-fast-restream.ts+++ b/server/tests/api/live/live-fast-restream.ts@@ -133,7 +133,7 @@ describe('Fast restream in live', function () {await setAccessTokensToServers([ server ])await setDefaultVideoChannel([ server ])- await server.config.enableMinimumTranscoding(false, true)+ await server.config.enableMinimumTranscoding({ webVideo: false, hls: true })await server.config.enableLive({ allowReplay: true, transcoding: true, resolutions: 'min' })})diff --git a/server/tests/api/runners/runner-common.ts b/server/tests/api/runners/runner-common.tsindex 7fed75f40c..9b2eb8b27e 100644--- a/server/tests/api/runners/runner-common.ts+++ b/server/tests/api/runners/runner-common.ts@@ -40,7 +40,7 @@ describe('Test runner common actions', function () {await setAccessTokensToServers([ server ])await setDefaultVideoChannel([ server ])- await server.config.enableTranscoding(true, true)+ await server.config.enableTranscoding({ hls: true, webVideo: true })await server.config.enableRemoteTranscoding()})diff --git a/server/tests/api/runners/runner-socket.ts b/server/tests/api/runners/runner-socket.tsindex a77e57a115..215164e484 100644--- a/server/tests/api/runners/runner-socket.ts+++ b/server/tests/api/runners/runner-socket.ts@@ -23,7 +23,7 @@ describe('Test runner socket', function () {await setAccessTokensToServers([ server ])await setDefaultVideoChannel([ server ])- await server.config.enableTranscoding(true, true)+ await server.config.enableTranscoding({ hls: true, webVideo: true })await server.config.enableRemoteTranscoding()runnerToken = await server.runners.autoRegisterRunner()})diff --git a/server/tests/api/runners/runner-studio-transcoding.ts b/server/tests/api/runners/runner-studio-transcoding.tsindex 443a9d02aa..f5cea6cea6 100644--- a/server/tests/api/runners/runner-studio-transcoding.ts+++ b/server/tests/api/runners/runner-studio-transcoding.ts@@ -53,7 +53,7 @@ describe('Test runner video studio transcoding', function () {await doubleFollow(servers[0], servers[1])- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true })await servers[0].config.enableStudio()await servers[0].config.enableRemoteStudio()diff --git a/server/tests/api/runners/runner-vod-transcoding.ts b/server/tests/api/runners/runner-vod-transcoding.tsindex ca16d9c10a..ee6be4ee97 100644--- a/server/tests/api/runners/runner-vod-transcoding.ts+++ b/server/tests/api/runners/runner-vod-transcoding.ts@@ -85,7 +85,7 @@ describe('Test runner VOD transcoding', function () {before(async function () {this.timeout(60000)- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true })})it('Should error a transcoding job', async function () {@@ -133,7 +133,7 @@ describe('Test runner VOD transcoding', function () {this.timeout(60000)await servers[0].runnerJobs.cancelAllJobs()- await servers[0].config.enableTranscoding(true, false)+ await servers[0].config.enableTranscoding({ hls: false, webVideo: true })const { uuid } = await servers[0].videos.quickUpload({ name: 'web video', fixture: 'video_short.webm' })videoUUID = uuid@@ -264,7 +264,7 @@ describe('Test runner VOD transcoding', function () {before(async function () {this.timeout(60000)- await servers[0].config.enableTranscoding(false, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: false })const { uuid } = await servers[0].videos.quickUpload({ name: 'hls video', fixture: 'video_short.webm' })videoUUID = uuid@@ -384,7 +384,7 @@ describe('Test runner VOD transcoding', function () {before(async function () {this.timeout(60000)- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true })await servers[0].videos.quickUpload({ name: 'web video and hls video', fixture: 'video_short.webm' })@@ -422,7 +422,7 @@ describe('Test runner VOD transcoding', function () {before(async function () {this.timeout(60000)- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true })const attributes = { name: 'audio_with_preview', previewfile: 'custom-preview.jpg', fixture: 'sample.ogg' }const { uuid } = await servers[0].videos.upload({ attributes, mode: 'legacy' })diff --git a/server/tests/api/videos/video-files.ts b/server/tests/api/videos/video-files.tsindex 0a183c44d8..4f75cd106f 100644--- a/server/tests/api/videos/video-files.ts+++ b/server/tests/api/videos/video-files.ts@@ -25,7 +25,7 @@ describe('Test videos files', function () {await doubleFollow(servers[0], servers[1])- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true })})describe('When deleting all files', function () {diff --git a/server/tests/api/videos/video-source.ts b/server/tests/api/videos/video-source.tsindex 8669f342e1..1f394f9047 100644--- a/server/tests/api/videos/video-source.ts+++ b/server/tests/api/videos/video-source.ts@@ -114,7 +114,7 @@ describe('Test a video file replacement', function () {const previousPaths: string[] = []- await servers[0].config.enableTranscoding(true, true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true })const { uuid: videoUUID } = await servers[0].videos.quickUpload({ name: 'fs with transcoding', fixture: 'video_short_720p.mp4' })uuid = videoUUID@@ -387,7 +387,7 @@ describe('Test a video file replacement', function () {const previousPaths: string[] = []- await servers[0].config.enableTranscoding(true, true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true })const { uuid: videoUUID } = await servers[0].videos.quickUpload({name: 'object storage with transcoding',diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.tsindex ba861164bc..f68560b06c 100644--- a/server/tests/api/videos/videos-common-filters.ts+++ b/server/tests/api/videos/videos-common-filters.ts@@ -468,19 +468,19 @@ describe('Test videos filter', function () {const finderFactory = (name: string) => (videos: Video[]) => videos.some(v => v.name === name)- await servers[0].config.enableTranscoding(true, false)+ await servers[0].config.enableTranscoding({ hls: false, webVideo: true })await servers[0].videos.upload({ attributes: { name: 'web video' } })const hasWebVideo = finderFactory('web video')await waitJobs(servers)- await servers[0].config.enableTranscoding(false, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: false })await servers[0].videos.upload({ attributes: { name: 'hls video' } })const hasHLS = finderFactory('hls video')await waitJobs(servers)- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true })await servers[0].videos.upload({ attributes: { name: 'hls and web video' } })const hasBoth = finderFactory('hls and web video')diff --git a/server/tests/peertube-runner/live-transcoding.ts b/server/tests/peertube-runner/live-transcoding.tsindex 4826c61f7e..41b01f8d59 100644--- a/server/tests/peertube-runner/live-transcoding.ts+++ b/server/tests/peertube-runner/live-transcoding.ts@@ -139,7 +139,7 @@ describe('Test Live transcoding in peertube-runner program', function () {sqlCommandServer1 = new SQLCommand(servers[0])await servers[0].config.enableRemoteTranscoding()- await servers[0].config.enableTranscoding(true, true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true })await servers[0].config.enableLive({ allowReplay: true, resolutions: 'max', transcoding: true })const registrationToken = await servers[0].runnerRegistrationTokens.getFirstRegistrationToken()@@ -152,7 +152,7 @@ describe('Test Live transcoding in peertube-runner program', function () {describe('With lives on local filesystem storage', function () {before(async function () {- await servers[0].config.enableTranscoding(true, false, true)+ await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true })})runSuite()diff --git a/server/tests/peertube-runner/studio-transcoding.ts b/server/tests/peertube-runner/studio-transcoding.tsindex c265d7934f..56bfef8970 100644--- a/server/tests/peertube-runner/studio-transcoding.ts+++ b/server/tests/peertube-runner/studio-transcoding.ts@@ -68,7 +68,7 @@ describe('Test studio transcoding in peertube-runner program', function () {await doubleFollow(servers[0], servers[1])- await servers[0].config.enableTranscoding(true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true })await servers[0].config.enableStudio()await servers[0].config.enableRemoteStudio()diff --git a/server/tests/peertube-runner/vod-transcoding.ts b/server/tests/peertube-runner/vod-transcoding.tsindex eef6faf4e9..b3b62e5e0e 100644--- a/server/tests/peertube-runner/vod-transcoding.ts+++ b/server/tests/peertube-runner/vod-transcoding.ts@@ -201,7 +201,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {expect(getAllFiles(video)).to.have.lengthOf(1)}- await servers[0].config.enableTranscoding(true, true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true })await servers[0].videos.runTranscoding({ transcodingType: 'web-video', videoId: uuid })await waitJobs(servers, { runnerJobs: true })@@ -259,7 +259,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {describe('Web video only enabled', function () {before(async function () {- await servers[0].config.enableTranscoding(true, false, true)+ await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true })})runSuite({ webVideoEnabled: true, hlsEnabled: false })@@ -268,7 +268,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {describe('HLS videos only enabled', function () {before(async function () {- await servers[0].config.enableTranscoding(false, true, true)+ await servers[0].config.enableTranscoding({ webVideo: false, hls: true, with0p: true })})runSuite({ webVideoEnabled: false, hlsEnabled: true })@@ -277,7 +277,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {describe('Web video & HLS enabled', function () {before(async function () {- await servers[0].config.enableTranscoding(true, true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true })})runSuite({ webVideoEnabled: true, hlsEnabled: true })@@ -303,7 +303,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {describe('Web video only enabled', function () {before(async function () {- await servers[0].config.enableTranscoding(true, false, true)+ await servers[0].config.enableTranscoding({ webVideo: true, hls: false, with0p: true })})runSuite({ webVideoEnabled: true, hlsEnabled: false, objectStorage })@@ -312,7 +312,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {describe('HLS videos only enabled', function () {before(async function () {- await servers[0].config.enableTranscoding(false, true, true)+ await servers[0].config.enableTranscoding({ webVideo: false, hls: true, with0p: true })})runSuite({ webVideoEnabled: false, hlsEnabled: true, objectStorage })@@ -321,7 +321,7 @@ describe('Test VOD transcoding in peertube-runner program', function () {describe('Web video & HLS enabled', function () {before(async function () {- await servers[0].config.enableTranscoding(true, true, true)+ await servers[0].config.enableTranscoding({ hls: true, webVideo: true, with0p: true })})runSuite({ webVideoEnabled: true, hlsEnabled: true, objectStorage })diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.tsindex 3521b2d69e..5ee2fe021c 100644--- a/shared/server-commands/server/config-command.ts+++ b/shared/server-commands/server/config-command.ts@@ -152,8 +152,13 @@ export class ConfigCommand extends AbstractCommand {})}- // TODO: convert args to object- enableTranscoding (webVideo = true, hls = true, with0p = false) {+ enableTranscoding (options: {+ webVideo?: boolean // default true+ hls?: boolean // default true+ with0p?: boolean // default false+ } = {}) {+ const { webVideo = true, hls = true, with0p = false } = options+return this.updateExistingSubConfig({newConfig: {transcoding: {@@ -175,8 +180,12 @@ export class ConfigCommand extends AbstractCommand {})}- // TODO: convert args to object- enableMinimumTranscoding (webVideo = true, hls = true) {+ enableMinimumTranscoding (options: {+ webVideo?: boolean // default true+ hls?: boolean // default true+ } = {}) {+ const { webVideo = true, hls = true } = options+return this.updateExistingSubConfig({newConfig: {transcoding: {