diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/create-transcoding-job.ts | 4 | ||||
-rw-r--r-- | scripts/optimize-old-videos.ts | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index 65e65b616..3a552c19a 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -47,13 +47,13 @@ async function run () { | |||
47 | if (!video) throw new Error('Video not found.') | 47 | if (!video) throw new Error('Video not found.') |
48 | 48 | ||
49 | const dataInput: VideoTranscodingPayload[] = [] | 49 | const dataInput: VideoTranscodingPayload[] = [] |
50 | const { videoFileResolution } = await video.getMaxQualityResolution() | 50 | const { resolution } = await video.getMaxQualityResolution() |
51 | 51 | ||
52 | // Generate HLS files | 52 | // Generate HLS files |
53 | if (options.generateHls || CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { | 53 | if (options.generateHls || CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { |
54 | const resolutionsEnabled = options.resolution | 54 | const resolutionsEnabled = options.resolution |
55 | ? [ options.resolution ] | 55 | ? [ options.resolution ] |
56 | : computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ]) | 56 | : computeResolutionsToTranscode(resolution, 'vod').concat([ resolution ]) |
57 | 57 | ||
58 | for (const resolution of resolutionsEnabled) { | 58 | for (const resolution of resolutionsEnabled) { |
59 | dataInput.push({ | 59 | dataInput.push({ |
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( |