]> 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 4e70ab853cac66dbb0b2704596e678e8552b2b7a..3b29c0ad49f1b75f62a293fb51d1b53f9489535a 100644 (file)
@@ -1,7 +1,19 @@
+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'
-import * as ffmpeg from 'fluent-ffmpeg'
+
+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
 }