Add resolution to create-transcoding-job script (#654)
* Add resolution to create-transcoding-job script * Requested changes
This commit is contained in:
parent
f3a2cf8d2f
commit
05623b9030
|
@ -8,6 +8,7 @@ import { JobQueue } from '../server/lib/job-queue'
|
||||||
|
|
||||||
program
|
program
|
||||||
.option('-v, --video [videoUUID]', 'Video UUID')
|
.option('-v, --video [videoUUID]', 'Video UUID')
|
||||||
|
.option('-r, --resolution [resolution]', 'Video resolution (integer)')
|
||||||
.parse(process.argv)
|
.parse(process.argv)
|
||||||
|
|
||||||
if (program['video'] === undefined) {
|
if (program['video'] === undefined) {
|
||||||
|
@ -15,6 +16,11 @@ if (program['video'] === undefined) {
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (program.resolution !== undefined && Number.isNaN(+program.resolution)) {
|
||||||
|
console.error('The resolution must be an integer (example: 1080).')
|
||||||
|
process.exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
run()
|
run()
|
||||||
.then(() => process.exit(0))
|
.then(() => process.exit(0))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
@ -30,7 +36,12 @@ async function run () {
|
||||||
|
|
||||||
const dataInput = {
|
const dataInput = {
|
||||||
videoUUID: video.uuid,
|
videoUUID: video.uuid,
|
||||||
isNewVideo: false
|
isNewVideo: false,
|
||||||
|
resolution: undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
if (program.resolution !== undefined) {
|
||||||
|
dataInput.resolution = program.resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
await JobQueue.Instance.init()
|
await JobQueue.Instance.init()
|
||||||
|
|
|
@ -22,6 +22,7 @@ const expect = chai.expect
|
||||||
|
|
||||||
describe('Test create transcoding jobs', function () {
|
describe('Test create transcoding jobs', function () {
|
||||||
let servers: ServerInfo[] = []
|
let servers: ServerInfo[] = []
|
||||||
|
let video1UUID: string
|
||||||
let video2UUID: string
|
let video2UUID: string
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
@ -36,9 +37,10 @@ describe('Test create transcoding jobs', function () {
|
||||||
await doubleFollow(servers[0], servers[1])
|
await doubleFollow(servers[0], servers[1])
|
||||||
|
|
||||||
// Upload two videos for our needs
|
// Upload two videos for our needs
|
||||||
await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' })
|
const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' })
|
||||||
const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' })
|
video1UUID = res1.body.video.uuid
|
||||||
video2UUID = res.body.video.uuid
|
const res2 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2' })
|
||||||
|
video2UUID = res2.body.video.uuid
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
@ -100,6 +102,30 @@ describe('Test create transcoding jobs', function () {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('Should run a transcoding job on video 1 with resolution', async function () {
|
||||||
|
this.timeout(60000)
|
||||||
|
|
||||||
|
const env = getEnvCli(servers[0])
|
||||||
|
await execCLI(`${env} npm run create-transcoding-job -- -v ${video1UUID} -r 480`)
|
||||||
|
|
||||||
|
await waitJobs(servers)
|
||||||
|
|
||||||
|
for (const server of servers) {
|
||||||
|
const res = await getVideosList(server.url)
|
||||||
|
const videos = res.body.data
|
||||||
|
expect(videos).to.have.lengthOf(2)
|
||||||
|
|
||||||
|
const res2 = await getVideo(server.url, video1UUID)
|
||||||
|
const videoDetail: VideoDetails = res2.body
|
||||||
|
|
||||||
|
expect(videoDetail.files).to.have.lengthOf(2)
|
||||||
|
|
||||||
|
expect(videoDetail.files[0].resolution.id).to.equal(720)
|
||||||
|
|
||||||
|
expect(videoDetail.files[1].resolution.id).to.equal(480)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
after(async function () {
|
after(async function () {
|
||||||
killallServers(servers)
|
killallServers(servers)
|
||||||
})
|
})
|
||||||
|
|
|
@ -92,6 +92,11 @@ You can use this script to force transcoding of an existing video.
|
||||||
```
|
```
|
||||||
$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID]
|
$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or to transcode to a specific resolution:
|
||||||
|
```
|
||||||
|
$ sudo -u peertube NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run create-transcoding-job -- -v [videoUUID] -r [resolution]
|
||||||
|
```
|
||||||
|
|
||||||
### create-import-video-file-job.js
|
### create-import-video-file-job.js
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue