aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
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 /shared/extra-utils
parentc826f34a45757b324a20f71665b44ed10e6953b5 (diff)
downloadPeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.gz
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.zst
PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.zip
Improve target bitrate calculation
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/miscs/generate.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/shared/extra-utils/miscs/generate.ts b/shared/extra-utils/miscs/generate.ts
index 8d6435481..a03a20049 100644
--- a/shared/extra-utils/miscs/generate.ts
+++ b/shared/extra-utils/miscs/generate.ts
@@ -1,8 +1,20 @@
1import { expect } from 'chai'
1import * as ffmpeg from 'fluent-ffmpeg' 2import * as ffmpeg from 'fluent-ffmpeg'
2import { ensureDir, pathExists } from 'fs-extra' 3import { ensureDir, pathExists } from 'fs-extra'
3import { dirname } from 'path' 4import { dirname } from 'path'
5import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils'
6import { getMaxBitrate } from '@shared/core-utils'
4import { buildAbsoluteFixturePath } from './tests' 7import { buildAbsoluteFixturePath } from './tests'
5 8
9async function ensureHasTooBigBitrate (fixturePath: string) {
10 const bitrate = await getVideoFileBitrate(fixturePath)
11 const dataResolution = await getVideoFileResolution(fixturePath)
12 const fps = await getVideoFileFPS(fixturePath)
13
14 const maxBitrate = getMaxBitrate({ ...dataResolution, fps })
15 expect(bitrate).to.be.above(maxBitrate)
16}
17
6async function generateHighBitrateVideo () { 18async function generateHighBitrateVideo () {
7 const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) 19 const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true)
8 20
@@ -28,6 +40,8 @@ async function generateHighBitrateVideo () {
28 }) 40 })
29 } 41 }
30 42
43 await ensureHasTooBigBitrate(tempFixturePath)
44
31 return tempFixturePath 45 return tempFixturePath
32} 46}
33 47