diff options
author | Chocobozzz <me@florianbigard.com> | 2023-06-01 14:51:16 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-06-29 10:16:55 +0200 |
commit | d8f39b126d9fe4bec1c12fb213548cc6edc87867 (patch) | |
tree | 7f0f1cb23165cf4dd789b2d78b1fef7ee116f647 /shared/ffmpeg/ffmpeg-images.ts | |
parent | 1fb7d094229acdc190c3f7551b43ac5445814dee (diff) | |
download | PeerTube-d8f39b126d9fe4bec1c12fb213548cc6edc87867.tar.gz PeerTube-d8f39b126d9fe4bec1c12fb213548cc6edc87867.tar.zst PeerTube-d8f39b126d9fe4bec1c12fb213548cc6edc87867.zip |
Add storyboard support
Diffstat (limited to 'shared/ffmpeg/ffmpeg-images.ts')
-rw-r--r-- | shared/ffmpeg/ffmpeg-images.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/shared/ffmpeg/ffmpeg-images.ts b/shared/ffmpeg/ffmpeg-images.ts index 2db63bd8b..27305382c 100644 --- a/shared/ffmpeg/ffmpeg-images.ts +++ b/shared/ffmpeg/ffmpeg-images.ts | |||
@@ -56,4 +56,41 @@ export class FFmpegImage { | |||
56 | .thumbnail(thumbnailOptions) | 56 | .thumbnail(thumbnailOptions) |
57 | }) | 57 | }) |
58 | } | 58 | } |
59 | |||
60 | async generateStoryboardFromVideo (options: { | ||
61 | path: string | ||
62 | destination: string | ||
63 | |||
64 | sprites: { | ||
65 | size: { | ||
66 | width: number | ||
67 | height: number | ||
68 | } | ||
69 | |||
70 | count: { | ||
71 | width: number | ||
72 | height: number | ||
73 | } | ||
74 | |||
75 | duration: number | ||
76 | } | ||
77 | }) { | ||
78 | const { path, destination, sprites } = options | ||
79 | |||
80 | const command = this.commandWrapper.buildCommand(path) | ||
81 | |||
82 | const filter = [ | ||
83 | `setpts=N/round(FRAME_RATE)/TB`, | ||
84 | `select='not(mod(t,${options.sprites.duration}))'`, | ||
85 | `scale=${sprites.size.width}:${sprites.size.height}`, | ||
86 | `tile=layout=${sprites.count.width}x${sprites.count.height}` | ||
87 | ].join(',') | ||
88 | |||
89 | command.outputOption('-filter_complex', filter) | ||
90 | command.outputOption('-frames:v', '1') | ||
91 | command.outputOption('-q:v', '2') | ||
92 | command.output(destination) | ||
93 | |||
94 | return this.commandWrapper.runCommand() | ||
95 | } | ||
59 | } | 96 | } |