1 import { FFmpegCommandWrapper, FFmpegCommandWrapperOptions } from './ffmpeg-command-wrapper'
3 export class FFmpegImage {
4 private readonly commandWrapper: FFmpegCommandWrapper
6 constructor (options: FFmpegCommandWrapperOptions) {
7 this.commandWrapper = new FFmpegCommandWrapper(options)
10 convertWebPToJPG (options: {
14 const { path, destination } = options
16 this.commandWrapper.buildCommand(path)
19 return this.commandWrapper.runCommand({ silent: true })
22 processGIF (options: {
25 newSize: { width: number, height: number }
27 const { path, destination, newSize } = options
29 this.commandWrapper.buildCommand(path)
31 .size(`${newSize.width}x${newSize.height}`)
34 return this.commandWrapper.runCommand()
37 async generateThumbnailFromVideo (options: {
42 const { fromPath, folder, imageName } = options
44 const pendingImageName = 'pending-' + imageName
46 const thumbnailOptions = {
47 filename: pendingImageName,
52 return new Promise<string>((res, rej) => {
53 this.commandWrapper.buildCommand(fromPath)
55 .on('end', () => res(imageName))
56 .thumbnail(thumbnailOptions)