From 9f1ddd249652c1e35b45db33885a00a005f9b059 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Oct 2018 16:50:56 +0200 Subject: Change a little bit optimize-old-videos logic --- server/lib/video-transcoding.ts | 14 +++++--------- server/models/video/video.ts | 10 ++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'server') diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index 04cadf74b..a78de61e5 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -1,5 +1,5 @@ import { CONFIG } from '../initializers' -import { join, extname, basename } from 'path' +import { extname, join } from 'path' import { getVideoFileFPS, getVideoFileResolution, transcode } from '../helpers/ffmpeg-utils' import { copy, remove, rename, stat } from 'fs-extra' import { logger } from '../helpers/logger' @@ -7,16 +7,12 @@ import { VideoResolution } from '../../shared/models/videos' import { VideoFileModel } from '../models/video/video-file' import { VideoModel } from '../models/video/video' -async function optimizeVideofile (video: VideoModel, videoInputPath?: string) { +async function optimizeVideofile (video: VideoModel, inputVideoFileArg?: VideoFileModel) { const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR const newExtname = '.mp4' - let inputVideoFile = null - if (videoInputPath == null) { - inputVideoFile = video.getOriginalFile() - videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) - } else { - inputVideoFile = basename(videoInputPath) - } + + const inputVideoFile = inputVideoFileArg ? inputVideoFileArg : video.getOriginalFile() + const videoInputPath = join(videosDirectory, video.getVideoFilename(inputVideoFile)) const videoTranscodedPath = join(videosDirectory, video.id + '-transcoded' + newExtname) const transcodeOptions = { diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 46d823240..070ac7623 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -788,6 +788,16 @@ export class VideoModel extends Model { return VideoModel.scope(ScopeNames.WITH_FILES).findAll() } + static listLocal () { + const query = { + where: { + remote: false + } + } + + return VideoModel.scope(ScopeNames.WITH_FILES).findAll(query) + } + static listAllAndSharedByActorForOutbox (actorId: number, start: number, count: number) { function getRawQuery (select: string) { const queryVideo = 'SELECT ' + select + ' FROM "video" AS "Video" ' + -- cgit v1.2.3