aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/optimize-old-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-06 13:35:25 +0200
committerChocobozzz <me@florianbigard.com>2021-08-06 14:13:26 +0200
commit679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 (patch)
tree03abf589275db05e5b1fa1c89f57049cd807324a /server/tests/cli/optimize-old-videos.ts
parentc826f34a45757b324a20f71665b44ed10e6953b5 (diff)
downloadPeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.gz
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.zst
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.zip
Improve target bitrate calculation
Diffstat (limited to 'server/tests/cli/optimize-old-videos.ts')
-rw-r--r--server/tests/cli/optimize-old-videos.ts20
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
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 })