diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/optimize-old-videos.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scripts/optimize-old-videos.ts b/scripts/optimize-old-videos.ts index 02026b3da..c93f82316 100644 --- a/scripts/optimize-old-videos.ts +++ b/scripts/optimize-old-videos.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' | 1 | import { CONFIG, VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' |
2 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' | 2 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' |
3 | import { getMaxBitrate } from '../shared/models/videos' | 3 | import { getMaxBitrate } from '../shared/models/videos' |
4 | import { VideoModel } from '../server/models/video/video' | 4 | import { VideoModel } from '../server/models/video/video' |
5 | import { optimizeVideofile } from '../server/lib/video-transcoding' | 5 | import { optimizeVideofile } from '../server/lib/video-transcoding' |
6 | import { initDatabaseModels } from '../server/initializers' | ||
7 | import { join } from 'path' | ||
6 | 8 | ||
7 | run() | 9 | run() |
8 | .then(() => process.exit(0)) | 10 | .then(() => process.exit(0)) |
@@ -12,11 +14,13 @@ run() | |||
12 | }) | 14 | }) |
13 | 15 | ||
14 | async function run () { | 16 | async function run () { |
17 | await initDatabaseModels(true) | ||
18 | |||
15 | const localVideos = await VideoModel.listLocal() | 19 | const localVideos = await VideoModel.listLocal() |
16 | 20 | ||
17 | for (const video of localVideos) { | 21 | for (const video of localVideos) { |
18 | for (const file of video.VideoFiles) { | 22 | for (const file of video.VideoFiles) { |
19 | const inputPath = video.getVideoFilename(file) | 23 | const inputPath = join(CONFIG.STORAGE.VIDEOS_DIR, video.getVideoFilename(file)) |
20 | 24 | ||
21 | const [ videoBitrate, fps, resolution ] = await Promise.all([ | 25 | const [ videoBitrate, fps, resolution ] = await Promise.all([ |
22 | getVideoFileBitrate(inputPath), | 26 | getVideoFileBitrate(inputPath), |