]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/video-transcoder.ts
Add tests for video downscale framerate matching
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / video-transcoder.ts
index 90ade16525aa35ae059ad90f7325e255c26420a9..0104c94fcb9b228f4cf90bcc1f84d792ec92204d 100644 (file)
@@ -11,6 +11,7 @@ import {
   doubleFollow,
   flushAndRunMultipleServers,
   generateHighBitrateVideo,
+  generateVideoWithFramerate,
   getMyVideos,
   getVideo,
   getVideosList,
@@ -292,7 +293,7 @@ describe('Test video transcoding', function () {
       tempFixturePath = await generateHighBitrateVideo()
 
       const bitrate = await getVideoFileBitrate(tempFixturePath)
-      expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS))
+      expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
     }
 
     const videoAttributes = {
@@ -331,7 +332,7 @@ describe('Test video transcoding', function () {
       tempFixturePath = await generateHighBitrateVideo()
 
       const bitrate = await getVideoFileBitrate(tempFixturePath)
-      expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 60, VIDEO_TRANSCODING_FPS))
+      expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS))
     }
 
     for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) {
@@ -416,6 +417,39 @@ describe('Test video transcoding', function () {
     }
   })
 
+  it('Should downscale to the closest divisor standard framerate', async function () {
+    this.timeout(160000)
+
+    let tempFixturePath: string
+
+    {
+      tempFixturePath = await generateVideoWithFramerate()
+
+      const fps = await getVideoFileFPS(tempFixturePath)
+      expect(fps).to.be.equal(59)
+    }
+
+    const videoAttributes = {
+      name: '59fps video',
+      description: '59fps video',
+      fixture: tempFixturePath
+    }
+
+    await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
+
+    await waitJobs(servers)
+
+    for (const server of servers) {
+      const res = await getVideosList(server.url)
+
+      const video = res.body.data.find(v => v.name === videoAttributes.name)
+      const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4')
+      const fps = await getVideoFileFPS(path)
+
+      expect(fps).to.be.equal(25)
+    }
+  })
+
   after(async function () {
     await cleanupTests(servers)
   })