diff options
author | Chocobozzz <me@florianbigard.com> | 2022-02-11 10:51:33 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-02-28 10:42:19 +0100 |
commit | c729caf6cc34630877a0e5a1bda1719384cd0c8a (patch) | |
tree | 1d2e13722e518c73d2c9e6f0969615e29d51cf8c /shared/server-commands/videos | |
parent | a24bf4dc659cebb65d887862bf21d7a35e9ec791 (diff) | |
download | PeerTube-c729caf6cc34630877a0e5a1bda1719384cd0c8a.tar.gz PeerTube-c729caf6cc34630877a0e5a1bda1719384cd0c8a.tar.zst PeerTube-c729caf6cc34630877a0e5a1bda1719384cd0c8a.zip |
Add basic video editor support
Diffstat (limited to 'shared/server-commands/videos')
-rw-r--r-- | shared/server-commands/videos/index.ts | 1 | ||||
-rw-r--r-- | shared/server-commands/videos/video-editor-command.ts | 67 |
2 files changed, 68 insertions, 0 deletions
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' | |||
12 | export * from './services-command' | 12 | export * from './services-command' |
13 | export * from './streaming-playlists-command' | 13 | export * from './streaming-playlists-command' |
14 | export * from './comments-command' | 14 | export * from './comments-command' |
15 | export * from './video-editor-command' | ||
15 | export * from './videos-command' | 16 | 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 @@ | |||
1 | import { HttpStatusCode, VideoEditorTask } from '@shared/models' | ||
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
3 | |||
4 | export class VideoEditorCommand extends AbstractCommand { | ||
5 | |||
6 | static getComplexTask (): VideoEditorTask[] { | ||
7 | return [ | ||
8 | // Total duration: 2 | ||
9 | { | ||
10 | name: 'cut', | ||
11 | options: { | ||
12 | start: 1, | ||
13 | end: 3 | ||
14 | } | ||
15 | }, | ||
16 | |||
17 | // Total duration: 7 | ||
18 | { | ||
19 | name: 'add-outro', | ||
20 | options: { | ||
21 | file: 'video_short.webm' | ||
22 | } | ||
23 | }, | ||
24 | |||
25 | { | ||
26 | name: 'add-watermark', | ||
27 | options: { | ||
28 | file: 'thumbnail.png' | ||
29 | } | ||
30 | }, | ||
31 | |||
32 | // Total duration: 9 | ||
33 | { | ||
34 | name: 'add-intro', | ||
35 | options: { | ||
36 | file: 'video_very_short_240p.mp4' | ||
37 | } | ||
38 | } | ||
39 | ] | ||
40 | } | ||
41 | |||
42 | createEditionTasks (options: OverrideCommandOptions & { | ||
43 | videoId: number | string | ||
44 | tasks: VideoEditorTask[] | ||
45 | }) { | ||
46 | const path = '/api/v1/videos/' + options.videoId + '/editor/edit' | ||
47 | const attaches: { [id: string]: any } = {} | ||
48 | |||
49 | for (let i = 0; i < options.tasks.length; i++) { | ||
50 | const task = options.tasks[i] | ||
51 | |||
52 | if (task.name === 'add-intro' || task.name === 'add-outro' || task.name === 'add-watermark') { | ||
53 | attaches[`tasks[${i}][options][file]`] = task.options.file | ||
54 | } | ||
55 | } | ||
56 | |||
57 | return this.postUploadRequest({ | ||
58 | ...options, | ||
59 | |||
60 | path, | ||
61 | attaches, | ||
62 | fields: { tasks: options.tasks }, | ||
63 | implicitToken: true, | ||
64 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
65 | }) | ||
66 | } | ||
67 | } | ||