]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-transcoder.ts
Add ability to filter my imports by target URL
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-transcoder.ts
index b3226dbf7289f869c2fb22639b1d6cbfbb2f15cd..d24a8f4e152273b55b1fe94893d03117a9d76d87 100644 (file)
@@ -3,29 +3,21 @@
 import 'mocha'
 import * as chai from 'chai'
 import { omit } from 'lodash'
-import { getMaxBitrate } from '@shared/core-utils'
+import { canDoQuickTranscode } from '@server/helpers/ffprobe-utils'
+import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared'
+import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'
+import { getAudioStream, getMetadataFromFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils'
+import { HttpStatusCode, VideoState } from '@shared/models'
 import {
-  buildAbsoluteFixturePath,
   cleanupTests,
   createMultipleServers,
   doubleFollow,
-  generateHighBitrateVideo,
-  generateVideoWithFramerate,
   makeGetRequest,
   PeerTubeServer,
   setAccessTokensToServers,
   waitJobs,
   webtorrentAdd
-} from '@shared/extra-utils'
-import { HttpStatusCode, VideoState } from '@shared/models'
-import {
-  canDoQuickTranscode,
-  getAudioStream,
-  getMetadataFromFile,
-  getVideoFileBitrate,
-  getVideoFileFPS,
-  getVideoFileResolution
-} from '../../../helpers/ffprobe-utils'
+} from '@shared/server-commands'
 
 const expect = chai.expect
 
@@ -583,7 +575,7 @@ describe('Test video transcoding', function () {
       }
     })
 
-    it('Should not transcode to an higher bitrate than the original file', async function () {
+    it('Should not transcode to an higher bitrate than the original file but above our low limit', async function () {
       this.timeout(160_000)
 
       const newConfig = {
@@ -622,7 +614,13 @@ describe('Test video transcoding', function () {
 
         const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
         const bitrate = await getVideoFileBitrate(path)
-        expect(bitrate, `${path} not below ${60_000}`).to.be.below(60_000)
+
+        const inputBitrate = 60_000
+        const limit = getMinLimitBitrate({ fps: 10, ratio: 1, resolution: r })
+        let belowValue = Math.max(inputBitrate, limit)
+        belowValue += belowValue * 0.20 // Apply 20% margin because bitrate control is not very precise
+
+        expect(bitrate, `${path} not below ${limit}`).to.be.below(belowValue)
       }
     })
   })