aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/optimize-old-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-10-18 16:53:52 +0200
committerChocobozzz <me@florianbigard.com>2018-10-18 16:54:26 +0200
commit74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15 (patch)
tree0fa74ef54f80cf5b2825f0b2d2d123e4c1aaa1dc /scripts/optimize-old-videos.ts
parentccbbe2b8d4b18d48d132058776c22397250a4a87 (diff)
downloadPeerTube-74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15.tar.gz
PeerTube-74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15.tar.zst
PeerTube-74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15.zip
Fix optimize old videos script
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),