import * as ffmpeg from 'fluent-ffmpeg'
+import { join } from 'path'
import { VideoResolution } from '../../shared/models/videos'
import { CONFIG, MAX_VIDEO_TRANSCODING_FPS } from '../initializers'
+import { unlinkPromise } from './core-utils'
import { processImage } from './image-utils'
-import { join } from 'path'
+import { logger } from './logger'
async function getVideoFileHeight (path: string) {
const videoStream = await getVideoFileStream(path)
folder
}
- await new Promise<string>((res, rej) => {
- ffmpeg(fromPath)
- .on('error', rej)
- .on('end', () => res(imageName))
- .thumbnail(options)
- })
-
const pendingImagePath = join(folder, pendingImageName)
- const destination = join(folder, imageName)
- await processImage({ path: pendingImagePath }, destination, size)
+
+ try {
+ await new Promise<string>((res, rej) => {
+ ffmpeg(fromPath)
+ .on('error', rej)
+ .on('end', () => res(imageName))
+ .thumbnail(options)
+ })
+
+ const destination = join(folder, imageName)
+ await processImage({ path: pendingImagePath }, destination, size)
+ } catch (err) {
+ logger.error('Cannot generate image from video %s.', fromPath, err)
+
+ try {
+ await unlinkPromise(pendingImagePath)
+ } catch (err) {
+ logger.debug('Cannot remove pending image path after generation error.', err)
+ }
+ }
}
type TranscodeOptions = {
+import { isTestInstance } from '../../helpers/core-utils'
import { logger } from '../../helpers/logger'
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
import { AbstractScheduler } from './abstract-scheduler'
}
async execute () {
- logger.info('Removing bad actor follows (scheduler).')
+ if (!isTestInstance()) logger.info('Removing bad actor follows (scheduler).')
try {
await ActorFollowModel.removeBadActorFollows()
+import { isTestInstance } from '../../helpers/core-utils'
import { logger } from '../../helpers/logger'
import { JobQueue } from '../job-queue'
import { AbstractScheduler } from './abstract-scheduler'
}
async execute () {
- logger.info('Removing old jobs (scheduler).')
+ if (!isTestInstance()) logger.info('Removing old jobs (scheduler).')
JobQueue.Instance.removeOldJobs()
}