From c729caf6cc34630877a0e5a1bda1719384cd0c8a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 11 Feb 2022 10:51:33 +0100 Subject: Add basic video editor support --- shared/server-commands/videos/index.ts | 1 + .../server-commands/videos/video-editor-command.ts | 67 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 shared/server-commands/videos/video-editor-command.ts (limited to 'shared/server-commands/videos') diff --git a/shared/server-commands/videos/index.ts b/shared/server-commands/videos/index.ts index 68a188b21..154aed9a6 100644 --- a/shared/server-commands/videos/index.ts +++ b/shared/server-commands/videos/index.ts @@ -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' diff --git a/shared/server-commands/videos/video-editor-command.ts b/shared/server-commands/videos/video-editor-command.ts new file mode 100644 index 000000000..485edce8e --- /dev/null +++ b/shared/server-commands/videos/video-editor-command.ts @@ -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 + }) + } +} -- cgit v1.2.3