X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=shared%2Fextra-utils%2Fmiscs%2Fgenerate.ts;h=3b29c0ad49f1b75f62a293fb51d1b53f9489535a;hb=62549e6c9818f422698f030e0b242609115493ed;hp=8d643548168119caf96497e93c94b5357a4f2e79;hpb=171efc48e67498406feb6d7873b3482b41505515;p=github%2FChocobozzz%2FPeerTube.git diff --git a/shared/extra-utils/miscs/generate.ts b/shared/extra-utils/miscs/generate.ts index 8d6435481..3b29c0ad4 100644 --- a/shared/extra-utils/miscs/generate.ts +++ b/shared/extra-utils/miscs/generate.ts @@ -1,8 +1,20 @@ -import * as ffmpeg from 'fluent-ffmpeg' +import { expect } from 'chai' +import ffmpeg from 'fluent-ffmpeg' import { ensureDir, pathExists } from 'fs-extra' import { dirname } from 'path' +import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@server/helpers/ffprobe-utils' +import { getMaxBitrate } from '@shared/core-utils' import { buildAbsoluteFixturePath } from './tests' +async function ensureHasTooBigBitrate (fixturePath: string) { + const bitrate = await getVideoFileBitrate(fixturePath) + const dataResolution = await getVideoFileResolution(fixturePath) + const fps = await getVideoFileFPS(fixturePath) + + const maxBitrate = getMaxBitrate({ ...dataResolution, fps }) + expect(bitrate).to.be.above(maxBitrate) +} + async function generateHighBitrateVideo () { const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) @@ -28,6 +40,8 @@ async function generateHighBitrateVideo () { }) } + await ensureHasTooBigBitrate(tempFixturePath) + return tempFixturePath }