aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/ffmpeg-utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/ffmpeg-utils.ts')
-rw-r--r--server/helpers/ffmpeg-utils.ts33
1 files changed, 6 insertions, 27 deletions
diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts
index 69defccc4..9755dd67c 100644
--- a/server/helpers/ffmpeg-utils.ts
+++ b/server/helpers/ffmpeg-utils.ts
@@ -64,35 +64,14 @@ function convertWebPToJPG (path: string, destination: string): Promise<void> {
64function processGIF ( 64function processGIF (
65 path: string, 65 path: string,
66 destination: string, 66 destination: string,
67 newSize: { width: number, height: number }, 67 newSize: { width: number, height: number }
68 keepOriginal = false
69): Promise<void> { 68): Promise<void> {
70 return new Promise<void>(async (res, rej) => { 69 const command = ffmpeg(path)
71 if (path === destination) { 70 .fps(20)
72 throw new Error('FFmpeg needs an input path different that the output path.') 71 .size(`${newSize.width}x${newSize.height}`)
73 } 72 .output(destination)
74
75 logger.debug('Processing gif %s to %s.', path, destination)
76 73
77 try { 74 return runCommand(command)
78 const command = ffmpeg(path)
79 .fps(20)
80 .size(`${newSize.width}x${newSize.height}`)
81 .output(destination)
82
83 command.on('error', (err, stdout, stderr) => {
84 logger.error('Error in ffmpeg gif resizing process.', { stdout, stderr })
85 return rej(err)
86 })
87 .on('end', async () => {
88 if (keepOriginal !== true) await remove(path)
89 res()
90 })
91 .run()
92 } catch (err) {
93 return rej(err)
94 }
95 })
96} 75}
97 76
98async function generateImageFromVideoFile (fromPath: string, folder: string, imageName: string, size: { width: number, height: number }) { 77async function generateImageFromVideoFile (fromPath: string, folder: string, imageName: string, size: { width: number, height: number }) {