1
0
Fork 0

Rename webtorrent config to web_videos

This commit is contained in:
Chocobozzz 2023-07-11 09:52:14 +02:00
parent 784e2ad5c3
commit c57ad141a9
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
36 changed files with 108 additions and 81 deletions

View File

@ -190,7 +190,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
hls: {
enabled: null
},
webtorrent: {
webVideos: {
enabled: null
},
remoteRunners: {

View File

@ -67,10 +67,10 @@
<div class="callout callout-light pt-2 mt-2 pb-0">
<h3 class="callout-title" i18n>Output formats</h3>
<ng-container formGroupName="webtorrent">
<ng-container formGroupName="webVideos">
<div class="form-group" [ngClass]="getTranscodingDisabledClass()">
<my-peertube-checkbox
inputName="transcodingWebTorrentEnabled" formControlName="enabled"
inputName="transcodingWebVideosEnabled" formControlName="enabled"
i18n-labelText labelText="Web Videos enabled"
>
<ng-template ptTemplate="help">

View File

@ -90,9 +90,9 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges {
const transcodingControl = this.form.get('transcoding.enabled')
const videoStudioControl = this.form.get('videoStudio.enabled')
const hlsControl = this.form.get('transcoding.hls.enabled')
const webtorrentControl = this.form.get('transcoding.webtorrent.enabled')
const webVideosControl = this.form.get('transcoding.webVideos.enabled')
webtorrentControl.valueChanges
webVideosControl.valueChanges
.subscribe(newValue => {
if (newValue === false && !hlsControl.disabled) {
hlsControl.disable()
@ -105,12 +105,12 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges {
hlsControl.valueChanges
.subscribe(newValue => {
if (newValue === false && !webtorrentControl.disabled) {
webtorrentControl.disable()
if (newValue === false && !webVideosControl.disabled) {
webVideosControl.disable()
}
if (newValue === true && !webtorrentControl.enabled) {
webtorrentControl.enable()
if (newValue === true && !webVideosControl.enabled) {
webVideosControl.enable()
}
})
@ -122,7 +122,7 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges {
})
transcodingControl.updateValueAndValidity()
webtorrentControl.updateValueAndValidity()
webVideosControl.updateValueAndValidity()
videoStudioControl.updateValueAndValidity()
hlsControl.updateValueAndValidity()
}

View File

@ -483,7 +483,7 @@ transcoding:
# Generate videos in a web compatible format
# If you also enabled the hls format, it will multiply videos storage by 2
# If disabled, breaks federation with PeerTube instances < 2.1
webtorrent:
web_videos:
enabled: false
# /!\ Requires ffmpeg >= 4.1

View File

@ -493,7 +493,7 @@ transcoding:
# Generate videos in a web compatible format
# If you also enabled the hls format, it will multiply videos storage by 2
# If disabled, breaks federation with PeerTube instances < 2.1
webtorrent:
web_videos:
enabled: false
# /!\ Requires ffmpeg >= 4.1

View File

@ -97,7 +97,7 @@ transcoding:
1080p: true
1440p: true
2160p: true
webtorrent:
web_videos:
enabled: true
hls:
enabled: true

View File

@ -242,8 +242,8 @@ function customConfig (): CustomConfig {
'2160p': CONFIG.TRANSCODING.RESOLUTIONS['2160p']
},
alwaysTranscodeOriginalResolution: CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION,
webtorrent: {
enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
webVideos: {
enabled: CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED
},
hls: {
enabled: CONFIG.TRANSCODING.HLS.ENABLED

View File

@ -120,8 +120,8 @@ async function generateNodeinfo (req: express.Request, res: express.Response) {
hls: {
enabled: CONFIG.TRANSCODING.HLS.ENABLED
},
webtorrent: {
enabled: CONFIG.TRANSCODING.WEBTORRENT.ENABLED
web_videos: {
enabled: CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED
},
enabledResolutions: ServerConfigManager.Instance.getEnabledResolutions('vod')
},

View File

@ -1,4 +1,5 @@
import config from 'config'
import { readFileSync, writeFileSync } from 'fs-extra'
import { URL } from 'url'
import { uniqify } from '@shared/core-utils'
import { getFFmpegVersion } from '@shared/ffmpeg'
@ -10,7 +11,7 @@ import { logger } from '../helpers/logger'
import { ApplicationModel, getServerActor } from '../models/application/application'
import { OAuthClientModel } from '../models/oauth/oauth-client'
import { UserModel } from '../models/user/user'
import { CONFIG, isEmailEnabled } from './config'
import { CONFIG, getLocalConfigFilePath, isEmailEnabled, reloadConfig } from './config'
import { WEBSERVER } from './constants'
async function checkActivityPubUrls () {
@ -37,10 +38,7 @@ function checkConfig () {
const configFiles = config.util.getConfigSources().map(s => s.name).join(' -> ')
logger.info('Using following configuration file hierarchy: %s.', configFiles)
// Moved configuration keys
if (config.has('services.csp-logger')) {
logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
}
checkRemovedConfigKeys()
checkSecretsConfig()
checkEmailConfig()
@ -104,6 +102,34 @@ export {
// ---------------------------------------------------------------------------
function checkRemovedConfigKeys () {
// Moved configuration keys
if (config.has('services.csp-logger')) {
logger.warn('services.csp-logger configuration has been renamed to csp.report_uri. Please update your configuration file.')
}
if (config.has('transcoding.webtorrent.enabled')) {
const localConfigPath = getLocalConfigFilePath()
const content = readFileSync(localConfigPath, { encoding: 'utf-8' })
if (!content.includes('"webtorrent"')) {
throw new Error('Please rename transcoding.webtorrent.enabled key to transcoding.web_videos.enabled in your configuration file')
}
try {
logger.info(
'Replacing "transcoding.webtorrent.enabled" key to "transcoding.web_videos.enabled" in your local configuration ' + localConfigPath
)
writeFileSync(localConfigPath, content.replace('"webtorrent"', '"web_videos"'), { encoding: 'utf-8' })
reloadConfig()
} catch (err) {
logger.error('Cannot write new configuration to file ' + localConfigPath, { err })
}
}
}
function checkSecretsConfig () {
if (!CONFIG.SECRETS.PEERTUBE) {
throw new Error('secrets.peertube is missing in config. Generate one using `openssl rand -hex 32`')
@ -198,7 +224,7 @@ function checkStorageConfig () {
function checkTranscodingConfig () {
if (CONFIG.TRANSCODING.ENABLED) {
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false && CONFIG.TRANSCODING.HLS.ENABLED === false) {
if (CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED === false && CONFIG.TRANSCODING.HLS.ENABLED === false) {
throw new Error('You need to enable at least Web Video transcoding or HLS transcoding.')
}

View File

@ -34,8 +34,8 @@ function checkMissedConfig () {
'signup.enabled', 'signup.limit', 'signup.requires_approval', 'signup.requires_email_verification', 'signup.minimum_age',
'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist',
'redundancy.videos.strategies', 'redundancy.videos.check_interval',
'transcoding.enabled', 'transcoding.threads', 'transcoding.allow_additional_extensions', 'transcoding.hls.enabled',
'transcoding.profile', 'transcoding.concurrency',
'transcoding.enabled', 'transcoding.threads', 'transcoding.allow_additional_extensions', 'transcoding.web_videos.enabled',
'transcoding.hls.enabled', 'transcoding.profile', 'transcoding.concurrency',
'transcoding.resolutions.0p', 'transcoding.resolutions.144p', 'transcoding.resolutions.240p', 'transcoding.resolutions.360p',
'transcoding.resolutions.480p', 'transcoding.resolutions.720p', 'transcoding.resolutions.1080p', 'transcoding.resolutions.1440p',
'transcoding.resolutions.2160p', 'transcoding.always_transcode_original_resolution', 'transcoding.remote_runners.enabled',

View File

@ -371,8 +371,8 @@ const CONFIG = {
HLS: {
get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') }
},
WEBTORRENT: {
get ENABLED () { return config.get<boolean>('transcoding.webtorrent.enabled') }
WEB_VIDEOS: {
get ENABLED () { return config.get<boolean>('transcoding.web_videos.enabled') }
},
REMOTE_RUNNERS: {
get ENABLED () { return config.get<boolean>('transcoding.remote_runners.enabled') }
@ -584,16 +584,6 @@ function isEmailEnabled () {
return false
}
// ---------------------------------------------------------------------------
export {
CONFIG,
registerConfigChangedHandler,
isEmailEnabled
}
// ---------------------------------------------------------------------------
function getLocalConfigFilePath () {
const localConfigDir = getLocalConfigDir()
@ -604,6 +594,17 @@ function getLocalConfigFilePath () {
return join(localConfigDir, filename + '.json')
}
// ---------------------------------------------------------------------------
export {
CONFIG,
getLocalConfigFilePath,
registerConfigChangedHandler,
isEmailEnabled
}
// ---------------------------------------------------------------------------
function getLocalConfigDir () {
if (process.env.PEERTUBE_LOCAL_CONFIG) return process.env.PEERTUBE_LOCAL_CONFIG

View File

@ -132,8 +132,8 @@ class ServerConfigManager {
hls: {
enabled: CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.HLS.ENABLED
},
webtorrent: {
enabled: CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.WEBTORRENT.ENABLED
web_videos: {
enabled: CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED
},
enabledResolutions: this.getEnabledResolutions('vod'),
profile: CONFIG.TRANSCODING.PROFILE,

View File

@ -60,7 +60,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
if (CONFIG.TRANSCODING.HLS.ENABLED === true) {
nextTranscodingSequentialJobPayloads.push([
this.buildHLSJobPayload({
deleteWebVideoFiles: CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false,
deleteWebVideoFiles: CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED === false,
// We had some issues with a web video quick transcoded while producing a HLS version of it
copyCodecs: !quickTranscode,
@ -208,7 +208,7 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
for (const resolution of resolutionsEnabled) {
const fps = computeOutputFPS({ inputFPS: inputVideoFPS, resolution })
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED) {
if (CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED) {
const payloads: (NewWebVideoResolutionTranscodingPayload | HLSTranscodingPayload)[] = [
this.buildWebVideoJobPayload({
videoUUID: video.uuid,

View File

@ -62,7 +62,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder {
if (CONFIG.TRANSCODING.HLS.ENABLED === true) {
await new VODHLSTranscodingJobHandler().create({
video,
deleteWebVideoFiles: CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false,
deleteWebVideoFiles: CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED === false,
resolution: maxResolution,
fps,
isNewVideo,
@ -169,7 +169,7 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder {
for (const resolution of resolutionsEnabled) {
const fps = computeOutputFPS({ inputFPS: inputVideoFPS, resolution })
if (CONFIG.TRANSCODING.WEBTORRENT.ENABLED) {
if (CONFIG.TRANSCODING.WEB_VIDEOS.ENABLED) {
await new VODWebVideoTranscodingJobHandler().create({
video,
resolution,

View File

@ -59,7 +59,7 @@ const customConfigUpdateValidator = [
body('transcoding.alwaysTranscodeOriginalResolution').isBoolean(),
body('transcoding.webtorrent.enabled').isBoolean(),
body('transcoding.webVideos.enabled').isBoolean(),
body('transcoding.hls.enabled').isBoolean(),
body('videoStudio.enabled').isBoolean(),
@ -153,8 +153,8 @@ function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: exp
function checkInvalidTranscodingConfig (customConfig: CustomConfig, res: express.Response) {
if (customConfig.transcoding.enabled === false) return true
if (customConfig.transcoding.webtorrent.enabled === false && customConfig.transcoding.hls.enabled === false) {
res.fail({ message: 'You need to enable at least webtorrent transcoding or hls transcoding' })
if (customConfig.transcoding.webVideos.enabled === false && customConfig.transcoding.hls.enabled === false) {
res.fail({ message: 'You need to enable at least web_videos transcoding or hls transcoding' })
return false
}

View File

@ -126,7 +126,7 @@ describe('Test config API validators', function () {
'2160p': false
},
alwaysTranscodeOriginalResolution: false,
webtorrent: {
webVideos: {
enabled: true
},
hls: {
@ -353,7 +353,7 @@ describe('Test config API validators', function () {
hls: {
enabled: false
},
webtorrent: {
web_videos: {
enabled: false
}
}

View File

@ -60,7 +60,7 @@ async function createServers (strategy: VideoRedundancyStrategy | null, addition
const config = {
transcoding: {
webtorrent: {
web_videos: {
enabled: withWebVideo
},
hls: {

View File

@ -79,7 +79,7 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) {
expect(data.transcoding.resolutions['1440p']).to.be.true
expect(data.transcoding.resolutions['2160p']).to.be.true
expect(data.transcoding.alwaysTranscodeOriginalResolution).to.be.true
expect(data.transcoding.webtorrent.enabled).to.be.true
expect(data.transcoding.webVideos.enabled).to.be.true
expect(data.transcoding.hls.enabled).to.be.true
expect(data.live.enabled).to.be.false
@ -192,7 +192,7 @@ function checkUpdatedConfig (data: CustomConfig) {
expect(data.transcoding.resolutions['2160p']).to.be.false
expect(data.transcoding.alwaysTranscodeOriginalResolution).to.be.false
expect(data.transcoding.hls.enabled).to.be.false
expect(data.transcoding.webtorrent.enabled).to.be.true
expect(data.transcoding.webVideos.enabled).to.be.true
expect(data.live.enabled).to.be.true
expect(data.live.allowReplay).to.be.true
@ -344,7 +344,7 @@ const newCustomConfig: CustomConfig = {
'2160p': false
},
alwaysTranscodeOriginalResolution: false,
webtorrent: {
webVideos: {
enabled: true
},
hls: {

View File

@ -194,7 +194,7 @@ describe('Test stats (excluding redundancy)', function () {
newConfig: {
transcoding: {
enabled: true,
webtorrent: {
webVideos: {
enabled: true
},
hls: {

View File

@ -37,7 +37,7 @@ describe('Test audio only video transcoding', function () {
hls: {
enabled: true
},
webtorrent: {
web_videos: {
enabled: true
}
}

View File

@ -165,7 +165,7 @@ function runTests (enableObjectStorage: boolean) {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(false),
webtorrent: {
webVideos: {
enabled: true
},
hls: {
@ -201,7 +201,7 @@ function runTests (enableObjectStorage: boolean) {
enabled: true,
resolutions: ConfigCommand.getCustomConfigResolutions(true),
webtorrent: {
webVideos: {
enabled: true
},
hls: {

View File

@ -136,7 +136,7 @@ describe('Test HLS videos', function () {
hls: {
enabled: true
},
webtorrent: {
webVideos: {
enabled: false
}
}

View File

@ -31,7 +31,7 @@ function updateConfigForTranscoding (server: PeerTubeServer) {
allowAdditionalExtensions: true,
allowAudioFiles: true,
hls: { enabled: true },
webtorrent: { enabled: true },
webVideos: { enabled: true },
resolutions: {
'0p': false,
'144p': true,
@ -333,7 +333,7 @@ describe('Test video transcoding', function () {
newConfig: {
transcoding: {
hls: { enabled: true },
webtorrent: { enabled: true },
webVideos: { enabled: true },
resolutions: {
'0p': false,
'144p': false,
@ -405,7 +405,7 @@ describe('Test video transcoding', function () {
newConfig: {
transcoding: {
hls: { enabled: true },
webtorrent: { enabled: true },
webVideos: { enabled: true },
resolutions: {
'0p': true,
'144p': false,
@ -586,7 +586,7 @@ describe('Test video transcoding', function () {
'1440p': true,
'2160p': true
},
webtorrent: { enabled: true },
web_videos: { enabled: true },
hls: { enabled: true }
}
}
@ -728,7 +728,7 @@ describe('Test video transcoding', function () {
transcoding: {
enabled: true,
hls: { enabled: true },
webtorrent: { enabled: true },
webVideos: { enabled: true },
resolutions: {
'0p': false,
'144p': false,

View File

@ -121,7 +121,7 @@ describe('Test update video privacy while transcoding', function () {
hls: {
enabled: true
},
webtorrent: {
webVideos: {
enabled: false
}
}

View File

@ -277,7 +277,7 @@ describe('Test video studio', function () {
await servers[0].config.updateExistingSubConfig({
newConfig: {
transcoding: {
webtorrent: {
webVideos: {
enabled: false
}
}

View File

@ -189,7 +189,7 @@ describe('Test user videos', function () {
{
const config = await server.config.getCustomConfig()
config.transcoding.webtorrent.enabled = false
config.transcoding.webVideos.enabled = false
config.transcoding.hls.enabled = true
config.transcoding.enabled = true
await server.config.updateCustomSubConfig({ newConfig: config })

View File

@ -328,7 +328,7 @@ describe('Test video imports', function () {
'1440p': false,
'2160p': false
},
webtorrent: { enabled: true },
webVideos: { enabled: true },
hls: { enabled: false }
}
}

View File

@ -47,7 +47,7 @@ describe('Test syndication feeds', () => {
serverHLSOnly = await createSingleServer(3, {
transcoding: {
enabled: true,
webtorrent: { enabled: false },
web_videos: { enabled: false },
hls: { enabled: true }
}
})

View File

@ -493,7 +493,7 @@ describe('Test plugin filter hooks', function () {
await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
webtorrent: {
webVideos: {
enabled: true
},
hls: {

View File

@ -35,7 +35,7 @@ function updateConf (server: PeerTubeServer, vodProfile: string, liveProfile: st
hls: {
enabled: true
},
webtorrent: {
webVideos: {
enabled: true
},
resolutions: {

View File

@ -28,7 +28,7 @@ async function completeWebVideoFilesCheck (options: {
const serverConfig = await originServer.config.getConfig()
const requiresAuth = video.privacy.id === VideoPrivacy.PRIVATE || video.privacy.id === VideoPrivacy.INTERNAL
const transcodingEnabled = serverConfig.transcoding.webtorrent.enabled
const transcodingEnabled = serverConfig.transcoding.web_videos.enabled
for (const attributeFile of files) {
const file = video.files.find(f => f.resolution.id === attributeFile.resolution)

View File

@ -133,7 +133,7 @@ export interface CustomConfig {
alwaysTranscodeOriginalResolution: boolean
webtorrent: {
webVideos: {
enabled: boolean
}

View File

@ -140,7 +140,7 @@ export interface ServerConfig {
enabled: boolean
}
webtorrent: {
web_videos: {
enabled: boolean
}

View File

@ -142,7 +142,7 @@ export class ConfigCommand extends AbstractCommand {
resolutions: ConfigCommand.getCustomConfigResolutions(true, with0p),
webtorrent: {
webVideos: {
enabled: webVideo
},
hls: {
@ -169,7 +169,7 @@ export class ConfigCommand extends AbstractCommand {
'240p': true
},
webtorrent: {
webVideos: {
enabled: webVideo
},
hls: {
@ -424,7 +424,7 @@ export class ConfigCommand extends AbstractCommand {
'2160p': false
},
alwaysTranscodeOriginalResolution: true,
webtorrent: {
webVideos: {
enabled: true
},
hls: {

View File

@ -7768,7 +7768,7 @@ components:
properties:
enabled:
type: boolean
webtorrent:
web_videos:
type: object
properties:
enabled:
@ -8134,7 +8134,7 @@ components:
type: boolean
2160p:
type: boolean
webtorrent:
web_videos:
type: object
description: Web Video specific settings
properties:

View File

@ -1,7 +1,7 @@
#
#
# This file will be read by node-config
# See https://github.com/node-config/node-config/wiki/Environment-Variables#custom-environment-variables
#
#
webserver:
hostname: "PEERTUBE_WEBSERVER_HOSTNAME"
@ -177,9 +177,9 @@ transcoding:
2160p:
__name: "PEERTUBE_TRANSCODING_2160P"
__format: "json"
webtorrent:
web_videos:
enabled:
__name: "PEERTUBE_TRANSCODING_WEBTORRENT_ENABLED"
__name: "PEERTUBE_TRANSCODING_WEB_VIDEOS_ENABLED"
__format: "json"
hls:
enabled: