X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fthumbnail.ts;h=aa2d7a8132923a77e0b0a1eaa9f34c0d861e0c3e;hb=a65858746c1d2904bf117e8d91816e752d4b94c4;hp=c085239880ded8dfbce700b10ce5b2b706ef0c98;hpb=91f8f8db97ffb83701c30f9cdb1e804670434eb0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index c08523988..aa2d7a813 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts @@ -1,8 +1,6 @@ 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' @@ -10,7 +8,7 @@ import { ThumbnailModel } from '../models/video/thumbnail' 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 } @@ -116,21 +114,22 @@ function generateVideoMiniature (options: { }) { 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 + }) }) }