import { join } from 'path'
-
-import { ThumbnailType } from '../../shared/models/videos/thumbnail.type'
-import { generateImageFromVideoFile } from '../helpers/ffmpeg-utils'
-import { generateImageFilename, processImage } from '../helpers/image-utils'
+import { ThumbnailType } from '@shared/models'
+import { generateImageFilename, generateImageFromVideoFile, processImage } from '../helpers/image-utils'
import { downloadImage } from '../helpers/requests'
import { CONFIG } from '../initializers/config'
import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants'
import { MVideoFile, MVideoThumbnail, MVideoUUID } from '../types/models'
import { MThumbnail } from '../types/models/video/thumbnail'
import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist'
-import { getVideoFilePath } from './video-paths'
+import { VideoPathManager } from './video-path-manager'
type ImageSize = { height?: number, width?: number }
}) {
const { video, videoFile, type } = options
- const input = getVideoFilePath(video, videoFile)
+ return VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), input => {
+ const { filename, basePath, height, width, existingThumbnail, outputPath } = buildMetadataFromVideo(video, type)
- const { filename, basePath, height, width, existingThumbnail, outputPath } = buildMetadataFromVideo(video, type)
- const thumbnailCreator = videoFile.isAudio()
- ? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true)
- : () => generateImageFromVideoFile(input, basePath, filename, { height, width })
+ const thumbnailCreator = videoFile.isAudio()
+ ? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true)
+ : () => generateImageFromVideoFile(input, basePath, filename, { height, width })
- return updateThumbnailFromFunction({
- thumbnailCreator,
- filename,
- height,
- width,
- type,
- automaticallyGenerated: true,
- existingThumbnail
+ return updateThumbnailFromFunction({
+ thumbnailCreator,
+ filename,
+ height,
+ width,
+ type,
+ automaticallyGenerated: true,
+ existingThumbnail
+ })
})
}