mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Add basic video editor support
This commit is contained in:
parent
a24bf4dc65
commit
c729caf6cc
130 changed files with 3969 additions and 1353 deletions
67
shared/server-commands/videos/video-editor-command.ts
Normal file
67
shared/server-commands/videos/video-editor-command.ts
Normal 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
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue