aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/optimize-old-videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/optimize-old-videos.ts')
-rw-r--r--scripts/optimize-old-videos.ts8
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 @@
1import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' 1import { CONFIG, VIDEO_TRANSCODING_FPS } from '../server/initializers/constants'
2import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils' 2import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffmpeg-utils'
3import { getMaxBitrate } from '../shared/models/videos' 3import { getMaxBitrate } from '../shared/models/videos'
4import { VideoModel } from '../server/models/video/video' 4import { VideoModel } from '../server/models/video/video'
5import { optimizeVideofile } from '../server/lib/video-transcoding' 5import { optimizeVideofile } from '../server/lib/video-transcoding'
6import { initDatabaseModels } from '../server/initializers'
7import { join } from 'path'
6 8
7run() 9run()
8 .then(() => process.exit(0)) 10 .then(() => process.exit(0))
@@ -12,11 +14,13 @@ run()
12 }) 14 })
13 15
14async function run () { 16async 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),