diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-18 16:53:52 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-10-18 16:54:26 +0200 |
commit | 74cd011b6c089cac88a4b8aa76ad3be2ca4f1c15 (patch) | |
tree | 0fa74ef54f80cf5b2825f0b2d2d123e4c1aaa1dc /scripts/optimize-old-videos.ts | |
parent | ccbbe2b8d4b18d48d132058776c22397250a4a87 (diff) | |
download | PeerTube-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.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), |