]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/miscs/generate.ts
Rewrite youtube-dl import
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / miscs / generate.ts
index 8d643548168119caf96497e93c94b5357a4f2e79..3b29c0ad49f1b75f62a293fb51d1b53f9489535a 100644 (file)
@@ -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
 }