aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/ffmpeg-utils.ts18
1 files changed, 11 insertions, 7 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index ad6f2f867..57911bc73 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -1,6 +1,8 @@
1import * as ffmpeg from 'fluent-ffmpeg' 1import * as ffmpeg from 'fluent-ffmpeg'
2import { VideoResolution } from '../../shared/models/videos' 2import { VideoResolution } from '../../shared/models/videos'
3import { CONFIG, MAX_VIDEO_TRANSCODING_FPS } from '../initializers' 3import { CONFIG, MAX_VIDEO_TRANSCODING_FPS } from '../initializers'
4import { processImage } from './image-utils'
5import { join } from 'path'
4 6
5async function getVideoFileHeight (path: string) { 7async function getVideoFileHeight (path: string) {
6 const videoStream = await getVideoFileStream(path) 8 const videoStream = await getVideoFileStream(path)
@@ -34,23 +36,25 @@ function getDurationFromVideoFile (path: string) {
34 }) 36 })
35} 37}
36 38
37function generateImageFromVideoFile (fromPath: string, folder: string, imageName: string, size: string) { 39async function generateImageFromVideoFile (fromPath: string, folder: string, imageName: string, size: { width: number, height: number }) {
40 const pendingImageName = 'pending-' + imageName
41
38 const options = { 42 const options = {
39 filename: imageName, 43 filename: pendingImageName,
40 count: 1, 44 count: 1,
41 folder 45 folder
42 } 46 }
43 47
44 if (size !== undefined) { 48 await new Promise<string>((res, rej) => {
45 options['size'] = size
46 }
47
48 return new Promise<string>((res, rej) => {
49 ffmpeg(fromPath) 49 ffmpeg(fromPath)
50 .on('error', rej) 50 .on('error', rej)
51 .on('end', () => res(imageName)) 51 .on('end', () => res(imageName))
52 .thumbnail(options) 52 .thumbnail(options)
53 }) 53 })
54
55 const pendingImagePath = join(folder, pendingImageName)
56 const destination = join(folder, imageName)
57 await processImage({ path: pendingImagePath }, destination, size)
54} 58}
55 59
56type TranscodeOptions = { 60type TranscodeOptions = {