aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--package.json2
-rwxr-xr-xscripts/create-transcoding-job.ts112
-rw-r--r--scripts/print-transcode-command.ts48
3 files changed, 0 insertions, 162 deletions
diff --git a/package.json b/package.json
index 45ecf953b..82304a710 100644
--- a/package.json
+++ b/package.json
@@ -44,11 +44,9 @@
44 "start": "node dist/server", 44 "start": "node dist/server",
45 "start:server": "node dist/server --no-client", 45 "start:server": "node dist/server --no-client",
46 "update-host": "node ./dist/scripts/update-host.js", 46 "update-host": "node ./dist/scripts/update-host.js",
47 "create-transcoding-job": "node ./dist/scripts/create-transcoding-job.js",
48 "regenerate-thumbnails": "node ./dist/scripts/regenerate-thumbnails.js", 47 "regenerate-thumbnails": "node ./dist/scripts/regenerate-thumbnails.js",
49 "create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js", 48 "create-import-video-file-job": "node ./dist/scripts/create-import-video-file-job.js",
50 "create-move-video-storage-job": "node ./dist/scripts/create-move-video-storage-job.js", 49 "create-move-video-storage-job": "node ./dist/scripts/create-move-video-storage-job.js",
51 "print-transcode-command": "node ./dist/scripts/print-transcode-command.js",
52 "test": "bash ./scripts/test.sh", 50 "test": "bash ./scripts/test.sh",
53 "help": "bash ./scripts/help.sh", 51 "help": "bash ./scripts/help.sh",
54 "generate-cli-doc": "bash ./scripts/generate-cli-doc.sh", 52 "generate-cli-doc": "bash ./scripts/generate-cli-doc.sh",
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts
deleted file mode 100755
index c77a5805f..000000000
--- a/scripts/create-transcoding-job.ts
+++ /dev/null
@@ -1,112 +0,0 @@
1import { program } from 'commander'
2import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
3import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg'
4import { CONFIG } from '@server/initializers/config'
5import { buildTranscodingJob } from '@server/lib/video'
6import { VideoState, VideoTranscodingPayload } from '@shared/models'
7import { initDatabaseModels } from '../server/initializers/database'
8import { JobQueue } from '../server/lib/job-queue'
9import { VideoModel } from '../server/models/video/video'
10
11program
12 .option('-v, --video [videoUUID]', 'Video UUID')
13 .option('-r, --resolution [resolution]', 'Video resolution (integer)')
14 .option('--generate-hls', 'Generate HLS playlist')
15 .parse(process.argv)
16
17const options = program.opts()
18
19if (options.video === undefined) {
20 console.error('All parameters are mandatory.')
21 process.exit(-1)
22}
23
24if (options.resolution !== undefined && Number.isNaN(+options.resolution)) {
25 console.error('The resolution must be an integer (example: 1080).')
26 process.exit(-1)
27}
28
29run()
30 .then(() => process.exit(0))
31 .catch(err => {
32 console.error(err)
33 process.exit(-1)
34 })
35
36async function run () {
37 await initDatabaseModels(true)
38
39 const uuid = toCompleteUUID(options.video)
40
41 if (isUUIDValid(uuid) === false) {
42 console.error('%s is not a valid video UUID.', options.video)
43 return
44 }
45
46 const video = await VideoModel.loadFull(uuid)
47 if (!video) throw new Error('Video not found.')
48
49 const dataInput: VideoTranscodingPayload[] = []
50 const maxResolution = video.getMaxQualityFile().resolution
51
52 // FIXME: check the file has audio
53 const hasAudio = true
54
55 // Generate HLS files
56 if (options.generateHls || CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) {
57 const resolutionsEnabled = options.resolution
58 ? [ parseInt(options.resolution) ]
59 : computeResolutionsToTranscode({ input: maxResolution, type: 'vod', includeInput: true, strictLower: false, hasAudio })
60
61 for (const resolution of resolutionsEnabled) {
62 dataInput.push({
63 type: 'new-resolution-to-hls' as 'new-resolution-to-hls',
64 videoUUID: video.uuid,
65 resolution,
66
67 hasAudio,
68
69 copyCodecs: false,
70 isNewVideo: false,
71 isMaxQuality: maxResolution === resolution,
72 autoDeleteWebTorrentIfNeeded: false
73 })
74 }
75 } else {
76 if (options.resolution !== undefined) {
77 dataInput.push({
78 type: 'new-resolution-to-webtorrent' as 'new-resolution-to-webtorrent',
79 videoUUID: video.uuid,
80
81 createHLSIfNeeded: true,
82
83 hasAudio,
84
85 isNewVideo: false,
86 resolution: parseInt(options.resolution)
87 })
88 } else {
89 if (video.VideoFiles.length === 0) {
90 console.error('Cannot regenerate webtorrent files with a HLS only video.')
91 return
92 }
93
94 dataInput.push({
95 type: 'optimize-to-webtorrent' as 'optimize-to-webtorrent',
96 videoUUID: video.uuid,
97 isNewVideo: false
98 })
99 }
100 }
101
102 JobQueue.Instance.init()
103
104 video.state = VideoState.TO_TRANSCODE
105 await video.save()
106
107 for (const d of dataInput) {
108 await JobQueue.Instance.createJob(await buildTranscodingJob(d))
109
110 console.log('Transcoding job for video %s created.', video.uuid)
111 }
112}
diff --git a/scripts/print-transcode-command.ts b/scripts/print-transcode-command.ts
deleted file mode 100644
index ac60ff8a5..000000000
--- a/scripts/print-transcode-command.ts
+++ /dev/null
@@ -1,48 +0,0 @@
1import { program } from 'commander'
2import ffmpeg from 'fluent-ffmpeg'
3import { exit } from 'process'
4import { buildVODCommand, runCommand, TranscodeVODOptions } from '@server/helpers/ffmpeg'
5import { VideoTranscodingProfilesManager } from '@server/lib/transcoding/default-transcoding-profiles'
6
7program
8 .arguments('<path>')
9 .requiredOption('-r, --resolution [resolution]', 'video resolution')
10 .action((path, cmd) => {
11 if (cmd.resolution !== undefined && Number.isNaN(+cmd.resolution)) {
12 console.error('The resolution must be an integer (example: 1080).')
13 process.exit(-1)
14 }
15
16 run(path, cmd)
17 .then(() => process.exit(0))
18 .catch(err => {
19 console.error(err)
20 process.exit(-1)
21 })
22 })
23 .parse(process.argv)
24
25async function run (path: string, cmd: any) {
26 const options = {
27 type: 'video' as 'video',
28 inputPath: path,
29 outputPath: '/dev/null',
30
31 availableEncoders: VideoTranscodingProfilesManager.Instance.getAvailableEncoders(),
32 profile: 'default',
33
34 resolution: +cmd.resolution
35 } as TranscodeVODOptions
36
37 let command = ffmpeg(options.inputPath)
38 .output(options.outputPath)
39
40 command = await buildVODCommand(command, options)
41
42 command.on('start', (cmdline) => {
43 console.log(cmdline)
44 exit()
45 })
46
47 await runCommand({ command })
48}