]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - scripts/create-transcoding-job.ts
Fix avatar image in channel page
[github/Chocobozzz/PeerTube.git] / scripts / create-transcoding-job.ts
CommitLineData
0c948c16
C
1import * as program from 'commander'
2import { createReadStream } from 'fs'
3import { join } from 'path'
4import { createInterface } from 'readline'
5import { VideoModel } from '../server/models/video/video'
6import { initDatabaseModels } from '../server/initializers'
7import { JobQueue } from '../server/lib/job-queue'
8
9program
10 .option('-v, --video [videoUUID]', 'Video UUID')
05623b90 11 .option('-r, --resolution [resolution]', 'Video resolution (integer)')
0c948c16
C
12 .parse(process.argv)
13
14if (program['video'] === undefined) {
15 console.error('All parameters are mandatory.')
16 process.exit(-1)
17}
18
05623b90
F
19if (program.resolution !== undefined && Number.isNaN(+program.resolution)) {
20 console.error('The resolution must be an integer (example: 1080).')
21 process.exit(-1)
22}
23
0c948c16
C
24run()
25 .then(() => process.exit(0))
26 .catch(err => {
27 console.error(err)
28 process.exit(-1)
29 })
30
31async function run () {
32 await initDatabaseModels(true)
33
34 const video = await VideoModel.loadByUUID(program['video'])
35 if (!video) throw new Error('Video not found.')
36
37 const dataInput = {
38 videoUUID: video.uuid,
05623b90
F
39 isNewVideo: false,
40 resolution: undefined
41 }
42
43 if (program.resolution !== undefined) {
44 dataInput.resolution = program.resolution
0c948c16
C
45 }
46
47 await JobQueue.Instance.init()
48 await JobQueue.Instance.createJob({ type: 'video-file', payload: dataInput })
49 console.log('Transcoding job for video %s created.', video.uuid)
50}