aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/cli')
-rw-r--r--server/tests/cli/optimize-old-videos.ts20
-rw-r--r--server/tests/cli/print-transcode-command.ts10
2 files changed, 12 insertions, 18 deletions
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index 579b2e7d8..9b75ae164 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -2,6 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { getMaxBitrate } from '@shared/core-utils'
5import { 6import {
6 cleanupTests, 7 cleanupTests,
7 createMultipleServers, 8 createMultipleServers,
@@ -12,9 +13,7 @@ import {
12 wait, 13 wait,
13 waitJobs 14 waitJobs
14} from '@shared/extra-utils' 15} from '@shared/extra-utils'
15import { getMaxBitrate, VideoResolution } from '@shared/models'
16import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils' 16import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils'
17import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants'
18 17
19const expect = chai.expect 18const expect = chai.expect
20 19
@@ -30,14 +29,7 @@ describe('Test optimize old videos', function () {
30 29
31 await doubleFollow(servers[0], servers[1]) 30 await doubleFollow(servers[0], servers[1])
32 31
33 let tempFixturePath: string 32 const tempFixturePath = await generateHighBitrateVideo()
34
35 {
36 tempFixturePath = await generateHighBitrateVideo()
37
38 const bitrate = await getVideoFileBitrate(tempFixturePath)
39 expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
40 }
41 33
42 // Upload two videos for our needs 34 // Upload two videos for our needs
43 await servers[0].videos.upload({ attributes: { name: 'video1', fixture: tempFixturePath } }) 35 await servers[0].videos.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
@@ -88,10 +80,12 @@ describe('Test optimize old videos', function () {
88 const path = servers[0].servers.buildWebTorrentFilePath(file.fileUrl) 80 const path = servers[0].servers.buildWebTorrentFilePath(file.fileUrl)
89 const bitrate = await getVideoFileBitrate(path) 81 const bitrate = await getVideoFileBitrate(path)
90 const fps = await getVideoFileFPS(path) 82 const fps = await getVideoFileFPS(path)
91 const resolution = await getVideoFileResolution(path) 83 const data = await getVideoFileResolution(path)
84
85 expect(data.resolution).to.equal(file.resolution.id)
92 86
93 expect(resolution.videoFileResolution).to.equal(file.resolution.id) 87 const maxBitrate = getMaxBitrate({ ...data, fps })
94 expect(bitrate).to.be.below(getMaxBitrate(resolution.videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) 88 expect(bitrate).to.be.below(maxBitrate)
95 } 89 }
96 } 90 }
97 }) 91 })
diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts
index 3a7969e68..e328a6072 100644
--- a/server/tests/cli/print-transcode-command.ts
+++ b/server/tests/cli/print-transcode-command.ts
@@ -3,16 +3,16 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils' 5import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils'
6import { CLICommand } from '@shared/extra-utils' 6import { getMaxBitrate } from '@shared/core-utils'
7import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos' 7import { buildAbsoluteFixturePath, CLICommand } from '@shared/extra-utils'
8import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' 8import { VideoResolution } from '../../../shared/models/videos'
9 9
10const expect = chai.expect 10const expect = chai.expect
11 11
12describe('Test create transcoding jobs', function () { 12describe('Test create transcoding jobs', function () {
13 13
14 it('Should print the correct command for each resolution', async function () { 14 it('Should print the correct command for each resolution', async function () {
15 const fixturePath = 'server/tests/fixtures/video_short.webm' 15 const fixturePath = buildAbsoluteFixturePath('video_short.webm')
16 const fps = await getVideoFileFPS(fixturePath) 16 const fps = await getVideoFileFPS(fixturePath)
17 const bitrate = await getVideoFileBitrate(fixturePath) 17 const bitrate = await getVideoFileBitrate(fixturePath)
18 18
@@ -21,7 +21,7 @@ describe('Test create transcoding jobs', function () {
21 VideoResolution.H_1080P 21 VideoResolution.H_1080P
22 ]) { 22 ]) {
23 const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) 23 const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`)
24 const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate) 24 const targetBitrate = Math.min(getMaxBitrate({ resolution, fps, ratio: 16 / 9 }), bitrate)
25 25
26 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) 26 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`)
27 expect(command).to.includes(`-y -acodec aac -vcodec libx264`) 27 expect(command).to.includes(`-y -acodec aac -vcodec libx264`)