diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-06 13:35:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-06 14:13:26 +0200 |
commit | 679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 (patch) | |
tree | 03abf589275db05e5b1fa1c89f57049cd807324a /shared/extra-utils/miscs | |
parent | c826f34a45757b324a20f71665b44ed10e6953b5 (diff) | |
download | PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.gz PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.zst PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.zip |
Improve target bitrate calculation
Diffstat (limited to 'shared/extra-utils/miscs')
-rw-r--r-- | shared/extra-utils/miscs/generate.ts | 14 |
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 @@ | |||
1 | import { expect } from 'chai' | ||
1 | import * as ffmpeg from 'fluent-ffmpeg' | 2 | import * as ffmpeg from 'fluent-ffmpeg' |
2 | import { ensureDir, pathExists } from 'fs-extra' | 3 | import { ensureDir, pathExists } from 'fs-extra' |
3 | import { dirname } from 'path' | 4 | import { dirname } from 'path' |
5 | import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils' | ||
6 | import { getMaxBitrate } from '@shared/core-utils' | ||
4 | import { buildAbsoluteFixturePath } from './tests' | 7 | import { buildAbsoluteFixturePath } from './tests' |
5 | 8 | ||
9 | async 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 | |||
6 | async function generateHighBitrateVideo () { | 18 | async 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 | ||