aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create-transcoding-job.ts4
-rw-r--r--scripts/optimize-old-videos.ts7
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 @@
1import { registerTSPaths } from '../server/helpers/register-ts-paths' 1import { registerTSPaths } from '../server/helpers/register-ts-paths'
2registerTSPaths() 2registerTSPaths()
3 3
4import { VIDEO_TRANSCODING_FPS } from '../server/initializers/constants'
5import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffprobe-utils' 4import { getDurationFromVideoFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../server/helpers/ffprobe-utils'
6import { getMaxBitrate } from '../shared/models/videos'
7import { VideoModel } from '../server/models/video/video' 5import { VideoModel } from '../server/models/video/video'
8import { optimizeOriginalVideofile } from '../server/lib/transcoding/video-transcoding' 6import { optimizeOriginalVideofile } from '../server/lib/transcoding/video-transcoding'
9import { initDatabaseModels } from '../server/initializers/database' 7import { initDatabaseModels } from '../server/initializers/database'
@@ -11,6 +9,7 @@ import { basename, dirname } from 'path'
11import { copy, move, remove } from 'fs-extra' 9import { copy, move, remove } from 'fs-extra'
12import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' 10import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
13import { getVideoFilePath } from '@server/lib/video-paths' 11import { getVideoFilePath } from '@server/lib/video-paths'
12import { getMaxBitrate } from '@shared/core-utils'
14 13
15run() 14run()
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(