diff options
-rwxr-xr-x | scripts/create-transcoding-job.ts | 13 | ||||
-rw-r--r-- | server/tests/cli/create-transcoding-job.ts | 32 | ||||
-rw-r--r-- | support/doc/tools.md | 5 |
3 files changed, 46 insertions, 4 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts index 463cdfad3..179fb4fa6 100755 --- a/scripts/create-transcoding-job.ts +++ b/scripts/create-transcoding-job.ts | |||
@@ -8,6 +8,7 @@ import { JobQueue } from '../server/lib/job-queue' | |||
8 | 8 | ||
9 | program | 9 | program |
10 | .option('-v, --video [videoUUID]', 'Video UUID') | 10 | .option('-v, --video [videoUUID]', 'Video UUID') |
11 | .option('-r, --resolution [resolution]', 'Video resolution (integer)') | ||
11 | .parse(process.argv) | 12 | .parse(process.argv) |
12 | 13 | ||
13 | if (program['video'] === undefined) { | 14 | if (program['video'] === undefined) { |
@@ -15,6 +16,11 @@ if (program['video'] === undefined) { | |||
15 | process.exit(-1) | 16 | process.exit(-1) |
16 | } | 17 | } |
17 | 18 | ||
19 | if (program.resolution !== undefined && Number.isNaN(+program.resolution)) { | ||
20 | console.error('The resolution must be an integer (example: 1080).') | ||
21 | process.exit(-1) | ||
22 | } | ||
23 | |||
18 | run() | 24 | run() |
19 | .then(() => process.exit(0)) | 25 | .then(() => process.exit(0)) |
20 | .catch(err => { | 26 | .catch(err => { |
@@ -30,7 +36,12 @@ async function run () { | |||
30 | 36 | ||
31 | const dataInput = { | 37 | const dataInput = { |
32 | videoUUID: video.uuid, | 38 | videoUUID: video.uuid, |
33 | isNewVideo: false | 39 | isNewVideo: false, |
40 | resolution: undefined | ||
41 | } | ||
42 | |||
43 | if (program.resolution !== undefined) { | ||
44 | dataInput.resolution = program.resolution | ||
34 | } | 45 | } |
35 | 46 | ||
36 | await JobQueue.Instance.init() | 47 | await JobQueue.Instance.init() |
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index e7c36f9c6..c2e3840c5 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts | |||
@@ -22,6 +22,7 @@ const expect = chai.expect | |||
22 | 22 | ||
23 | describe('Test create transcoding jobs', function () { | 23 | describe('Test create transcoding jobs', function () { |
24 | let servers: ServerInfo[] = [] | 24 | let servers: ServerInfo[] = [] |
25 | let video1UUID: string | ||
25 | let video2UUID: string | 26 | let video2UUID: string |
26 | 27 | ||
27 | before(async function () { | 28 | before(async function () { |
@@ -36,9 +37,10 @@ describe('Test create transcoding jobs', function () { | |||
36 | await doubleFollow(servers[0], servers[1]) | 37 | await doubleFollow(servers[0], servers[1]) |
37 | 38 | ||
38 | // Upload two videos for our needs | 39 | // Upload two videos for our needs |
39 | await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) | 40 | const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) |
40 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' }) | 41 | video1UUID = res1.body.video.uuid |
41 | video2UUID = res.body.video.uuid | 42 | const res2 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' }) |
43 | video2UUID = res2.body.video.uuid | ||
42 | 44 | ||
43 | await waitJobs(servers) | 45 | await waitJobs(servers) |
44 | }) | 46 | }) |
@@ -100,6 +102,30 @@ describe('Test create transcoding jobs', function () { | |||
100 | } | 102 | } |
101 | }) | 103 | }) |
102 | 104 | ||
105 | it('Should run a transcoding job on video 1 with resolution', async function () { | ||
106 | this.timeout(60000) | ||
107 | |||
108 | const env = getEnvCli(servers[0]) | ||
109 | await execCLI(`${env} npm run create-transcoding-job -- -v ${video1UUID} -r 480`) | ||
110 | |||
111 | await waitJobs(servers) | ||
112 | |||
113 | for (const server of servers) { | ||
114 | const res = await getVideosList(server.url) | ||
115 | const videos = res.body.data | ||
116 | expect(videos).to.have.lengthOf(2) | ||
117 | |||
118 | const res2 = await getVideo(server.url, video1UUID) | ||
119 | const videoDetail: VideoDetails = res2.body | ||
120 | |||
121 | expect(videoDetail.files).to.have.lengthOf(2) | ||
122 | |||
123 | expect(videoDetail.files[0].resolution.id).to.equal(720) | ||
124 | |||
125 | expect(videoDetail.files[1].resolution.id).to.equal(480) | ||
126 | } | ||
127 | }) | ||
128 | |||
103 | after(async function () { | 129 | after(async function () { |
104 | killallServers(servers) | 130 | killallServers(servers) |
105 | }) | 131 | }) |
diff --git a/support/doc/tools.md b/support/doc/tools.md index 26b44c835..0addc0803 100644 --- a/support/doc/tools.md +++ b/support/doc/tools.md | |||
@@ -92,6 +92,11 @@ You can use this script to force transcoding of an existing video. | |||
92 | ``` | 92 | ``` |
93 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] | 93 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] |
94 | ``` | 94 | ``` |
95 | |||
96 | Or to transcode to a specific resolution: | ||
97 | ``` | ||
98 | $ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution] | ||
99 | ``` | ||
95 | 100 | ||
96 | ### create-import-video-file-job.js | 101 | ### create-import-video-file-job.js |
97 | 102 | ||