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

Add basic video editor support

This commit is contained in:
Chocobozzz 2022-02-11 10:51:33 +01:00 committed by Chocobozzz
parent a24bf4dc65
commit c729caf6cc
130 changed files with 3969 additions and 1353 deletions

View file

@ -59,6 +59,9 @@ export class ConfigCommand extends AbstractCommand {
newConfig: {
transcoding: {
enabled: false
},
videoEditor: {
enabled: false
}
}
})
@ -69,6 +72,10 @@ export class ConfigCommand extends AbstractCommand {
newConfig: {
transcoding: {
enabled: true,
allowAudioFiles: true,
allowAdditionalExtensions: true,
resolutions: ConfigCommand.getCustomConfigResolutions(true),
webtorrent: {
@ -82,6 +89,28 @@ export class ConfigCommand extends AbstractCommand {
})
}
enableMinimumTranscoding (webtorrent = true, hls = true) {
return this.updateExistingSubConfig({
newConfig: {
transcoding: {
enabled: true,
resolutions: {
...ConfigCommand.getCustomConfigResolutions(false),
'240p': true
},
webtorrent: {
enabled: webtorrent
},
hls: {
enabled: hls
}
}
}
})
}
getConfig (options: OverrideCommandOptions = {}) {
const path = '/api/v1/config'
@ -148,7 +177,7 @@ export class ConfigCommand extends AbstractCommand {
async updateExistingSubConfig (options: OverrideCommandOptions & {
newConfig: DeepPartial<CustomConfig>
}) {
const existing = await this.getCustomConfig(options)
const existing = await this.getCustomConfig({ ...options, expectedStatus: HttpStatusCode.OK_200 })
return this.updateCustomConfig({ ...options, newCustomConfig: merge({}, existing, options.newConfig) })
}
@ -282,6 +311,9 @@ export class ConfigCommand extends AbstractCommand {
}
}
},
videoEditor: {
enabled: false
},
import: {
videos: {
concurrency: 3,

View file

@ -25,6 +25,7 @@ import {
PlaylistsCommand,
ServicesCommand,
StreamingPlaylistsCommand,
VideoEditorCommand,
VideosCommand
} from '../videos'
import { CommentsCommand } from '../videos/comments-command'
@ -124,6 +125,7 @@ export class PeerTubeServer {
login?: LoginCommand
users?: UsersCommand
objectStorage?: ObjectStorageCommand
videoEditor?: VideoEditorCommand
videos?: VideosCommand
constructor (options: { serverNumber: number } | { url: string }) {
@ -394,5 +396,6 @@ export class PeerTubeServer {
this.users = new UsersCommand(this)
this.videos = new VideosCommand(this)
this.objectStorage = new ObjectStorageCommand(this)
this.videoEditor = new VideoEditorCommand(this)
}
}

View file

@ -12,4 +12,5 @@ export * from './playlists-command'
export * from './services-command'
export * from './streaming-playlists-command'
export * from './comments-command'
export * from './video-editor-command'
export * from './videos-command'

View file

@ -0,0 +1,67 @@
import { HttpStatusCode, VideoEditorTask } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class VideoEditorCommand extends AbstractCommand {
static getComplexTask (): VideoEditorTask[] {
return [
// Total duration: 2
{
name: 'cut',
options: {
start: 1,
end: 3
}
},
// Total duration: 7
{
name: 'add-outro',
options: {
file: 'video_short.webm'
}
},
{
name: 'add-watermark',
options: {
file: 'thumbnail.png'
}
},
// Total duration: 9
{
name: 'add-intro',
options: {
file: 'video_very_short_240p.mp4'
}
}
]
}
createEditionTasks (options: OverrideCommandOptions & {
videoId: number | string
tasks: VideoEditorTask[]
}) {
const path = '/api/v1/videos/' + options.videoId + '/editor/edit'
const attaches: { [id: string]: any } = {}
for (let i = 0; i < options.tasks.length; i++) {
const task = options.tasks[i]
if (task.name === 'add-intro' || task.name === 'add-outro' || task.name === 'add-watermark') {
attaches[`tasks[${i}][options][file]`] = task.options.file
}
}
return this.postUploadRequest({
...options,
path,
attaches,
fields: { tasks: options.tasks },
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
})
}
}