diff options
Diffstat (limited to 'scripts/optimize-old-videos.ts')
-rw-r--r-- | scripts/optimize-old-videos.ts | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/scripts/optimize-old-videos.ts b/scripts/optimize-old-videos.ts index bde9d1e01..9e66105dd 100644 --- a/scripts/optimize-old-videos.ts +++ b/scripts/optimize-old-videos.ts | |||
@@ -1,9 +1,7 @@ | |||
1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' | 1 | import { registerTSPaths } from '../server/helpers/register-ts-paths' |
2 | registerTSPaths() | 2 | registerTSPaths() |
3 | 3 | ||
4 | import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants' | ||
5 | import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffprobe-utils' | 4 | import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffprobe-utils' |
6 | import { getMaxBitrate } from '../shared/models/videos' | ||
7 | import { VideoModel } from '../server/models/video/video' | 5 | import { VideoModel } from '../server/models/video/video' |
8 | import { optimizeOriginalVideofile } from '../server/lib/transcoding/video-transcoding' | 6 | import { optimizeOriginalVideofile } from '../server/lib/transcoding/video-transcoding' |
9 | import { initDatabaseModels } from '../server/initializers/database' | 7 | import { initDatabaseModels } from '../server/initializers/database' |
@@ -11,6 +9,7 @@ import { basename, dirname } from 'path' | |||
11 | import { copy, move, remove } from 'fs-extra' | 9 | import { copy, move, remove } from 'fs-extra' |
12 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 10 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
13 | import { getVideoFilePath } from '@server/lib/video-paths' | 11 | import { getVideoFilePath } from '@server/lib/video-paths' |
12 | import { getMaxBitrate } from '@shared/core-utils' | ||
14 | 13 | ||
15 | run() | 14 | run() |
16 | .then(() => process.exit(0)) | 15 | .then(() => process.exit(0)) |
@@ -42,13 +41,13 @@ async function run () { | |||
42 | for (const file of video.VideoFiles) { | 41 | for (const file of video.VideoFiles) { |
43 | currentFilePath = getVideoFilePath(video, file) | 42 | currentFilePath = getVideoFilePath(video, file) |
44 | 43 | ||
45 | const [ videoBitrate, fps, resolution ] = await Promise.all([ | 44 | const [ videoBitrate, fps, dataResolution ] = await Promise.all([ |
46 | getVideoFileBitrate(currentFilePath), | 45 | getVideoFileBitrate(currentFilePath), |
47 | getVideoFileFPS(currentFilePath), | 46 | getVideoFileFPS(currentFilePath), |
48 | getVideoFileResolution(currentFilePath) | 47 | getVideoFileResolution(currentFilePath) |
49 | ]) | 48 | ]) |
50 | 49 | ||
51 | const maxBitrate = getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS) | 50 | const maxBitrate = getMaxBitrate({ ...dataResolution, fps }) |
52 | const isMaxBitrateExceeded = videoBitrate > maxBitrate | 51 | const isMaxBitrateExceeded = videoBitrate > maxBitrate |
53 | if (isMaxBitrateExceeded) { | 52 | if (isMaxBitrateExceeded) { |
54 | console.log( | 53 | console.log( |