1 import ffmpeg from 'fluent-ffmpeg'
2 import { FFMPEG_NICE } from '@server/initializers/constants'
3 import { runCommand } from './ffmpeg-commons'
5 function convertWebPToJPG (path: string, destination: string): Promise<void> {
6 const command = ffmpeg(path, { niceness: FFMPEG_NICE.THUMBNAIL })
9 return runCommand({ command, silent: true })
15 newSize: { width: number, height: number }
17 const command = ffmpeg(path, { niceness: FFMPEG_NICE.THUMBNAIL })
19 .size(`${newSize.width}x${newSize.height}`)
22 return runCommand({ command })
25 async function generateThumbnailFromVideo (fromPath: string, folder: string, imageName: string) {
26 const pendingImageName = 'pending-' + imageName
29 filename: pendingImageName,
34 return new Promise<string>((res, rej) => {
35 ffmpeg(fromPath, { niceness: FFMPEG_NICE.THUMBNAIL })
37 .on('end', () => res(imageName))
45 generateThumbnailFromVideo