diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-11 15:40:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-11 15:40:54 +0100 |
commit | 20eb3a5be018dc207253a54bac2e971cbf2c25ce (patch) | |
tree | b270ecfb43de02caef4f06aa58e805f6ffc00b8c /scripts | |
parent | ff9112ad21535938940d48d2355ba6ff43b33df8 (diff) | |
download | PeerTube-20eb3a5be018dc207253a54bac2e971cbf2c25ce.tar.gz PeerTube-20eb3a5be018dc207253a54bac2e971cbf2c25ce.tar.zst PeerTube-20eb3a5be018dc207253a54bac2e971cbf2c25ce.zip |
Fix create transcoding job script
Depending on the file and the webtorrent/hls config
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/create-transcoding-job.ts | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index 5f56d6d36..9f1d8b956 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -7,6 +7,7 @@ import { initDatabaseModels } from '../server/initializers/database' | |||
7 | import { JobQueue } from '../server/lib/job-queue' | 7 | import { JobQueue } from '../server/lib/job-queue' |
8 | import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils' | 8 | import { computeResolutionsToTranscode } from '@server/helpers/ffprobe-utils' |
9 | import { VideoTranscodingPayload } from '@shared/models' | 9 | import { VideoTranscodingPayload } from '@shared/models' |
10 | import { CONFIG } from '@server/initializers/config' | ||
10 | 11 | ||
11 | program | 12 | program |
12 | .option('-v, --video [videoUUID]', 'Video UUID') | 13 | .option('-v, --video [videoUUID]', 'Video UUID') |
@@ -42,7 +43,8 @@ async function run () { | |||
42 | const dataInput: VideoTranscodingPayload[] = [] | 43 | const dataInput: VideoTranscodingPayload[] = [] |
43 | const { videoFileResolution } = await video.getMaxQualityResolution() | 44 | const { videoFileResolution } = await video.getMaxQualityResolution() |
44 | 45 | ||
45 | if (options.generateHls) { | 46 | // Generate HLS files |
47 | if (options.generateHls || CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { | ||
46 | const resolutionsEnabled = options.resolution | 48 | const resolutionsEnabled = options.resolution |
47 | ? [ options.resolution ] | 49 | ? [ options.resolution ] |
48 | : computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ]) | 50 | : computeResolutionsToTranscode(videoFileResolution, 'vod').concat([ videoFileResolution ]) |
@@ -57,19 +59,26 @@ async function run () { | |||
57 | isMaxQuality: false | 59 | isMaxQuality: false |
58 | }) | 60 | }) |
59 | } | 61 | } |
60 | } else if (options.resolution !== undefined) { | ||
61 | dataInput.push({ | ||
62 | type: 'new-resolution-to-webtorrent', | ||
63 | videoUUID: video.uuid, | ||
64 | isNewVideo: false, | ||
65 | resolution: options.resolution | ||
66 | }) | ||
67 | } else { | 62 | } else { |
68 | dataInput.push({ | 63 | if (options.resolution !== undefined) { |
69 | type: 'optimize-to-webtorrent', | 64 | dataInput.push({ |
70 | videoUUID: video.uuid, | 65 | type: 'new-resolution-to-webtorrent', |
71 | isNewVideo: false | 66 | videoUUID: video.uuid, |
72 | }) | 67 | isNewVideo: false, |
68 | resolution: options.resolution | ||
69 | }) | ||
70 | } else { | ||
71 | if (video.VideoFiles.length === 0) { | ||
72 | console.error('Cannot regenerate webtorrent files with a HLS only video.') | ||
73 | return | ||
74 | } | ||
75 | |||
76 | dataInput.push({ | ||
77 | type: 'optimize-to-webtorrent', | ||
78 | videoUUID: video.uuid, | ||
79 | isNewVideo: false | ||
80 | }) | ||
81 | } | ||
73 | } | 82 | } |
74 | 83 | ||
75 | await JobQueue.Instance.init() | 84 | await JobQueue.Instance.init() |