diff options
Diffstat (limited to 'server/tests/cli/optimize-old-videos.ts')
-rw-r--r-- | server/tests/cli/optimize-old-videos.ts | 20 |
1 files changed, 7 insertions, 13 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 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { getMaxBitrate } from '@shared/core-utils' | ||
5 | import { | 6 | import { |
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' |
15 | import { getMaxBitrate, VideoResolution } from '@shared/models' | ||
16 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils' | 16 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils' |
17 | import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' | ||
18 | 17 | ||
19 | const expect = chai.expect | 18 | const 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 | }) |