aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/videos/multiple-servers.ts13
-rw-r--r--server/tests/api/videos/video-transcoder.ts12
-rw-r--r--server/tests/cli/print-transcode-command.ts9
3 files changed, 20 insertions, 14 deletions
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 9c255c1c5..470bee45b 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -591,7 +591,9 @@ describe('Test multiple servers', function () {
591 }) 591 })
592 592
593 describe('Should manipulate these videos', function () { 593 describe('Should manipulate these videos', function () {
594 it('Should update the video 3 by asking server 3', async function () { 594 let updatedAtMin: Date
595
596 it('Should update video 3', async function () {
595 this.timeout(10000) 597 this.timeout(10000)
596 598
597 const attributes = { 599 const attributes = {
@@ -608,6 +610,7 @@ describe('Test multiple servers', function () {
608 previewfile: 'preview.jpg' 610 previewfile: 'preview.jpg'
609 } 611 }
610 612
613 updatedAtMin = new Date()
611 await servers[2].videos.update({ id: toRemove[0].id, attributes }) 614 await servers[2].videos.update({ id: toRemove[0].id, attributes })
612 615
613 await waitJobs(servers) 616 await waitJobs(servers)
@@ -622,6 +625,8 @@ describe('Test multiple servers', function () {
622 const videoUpdated = data.find(video => video.name === 'my super video updated') 625 const videoUpdated = data.find(video => video.name === 'my super video updated')
623 expect(!!videoUpdated).to.be.true 626 expect(!!videoUpdated).to.be.true
624 627
628 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
629
625 const isLocal = server.url === 'http://localhost:' + servers[2].port 630 const isLocal = server.url === 'http://localhost:' + servers[2].port
626 const checkAttributes = { 631 const checkAttributes = {
627 name: 'my super video updated', 632 name: 'my super video updated',
@@ -1024,15 +1029,15 @@ describe('Test multiple servers', function () {
1024 files: [ 1029 files: [
1025 { 1030 {
1026 resolution: 720, 1031 resolution: 720,
1027 size: 59000 1032 size: 61000
1028 }, 1033 },
1029 { 1034 {
1030 resolution: 480, 1035 resolution: 480,
1031 size: 34000 1036 size: 40000
1032 }, 1037 },
1033 { 1038 {
1034 resolution: 360, 1039 resolution: 360,
1035 size: 31000 1040 size: 32000
1036 }, 1041 },
1037 { 1042 {
1038 resolution: 240, 1043 resolution: 240,
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index b3226dbf7..7ed55b8e8 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { getMaxBitrate } from '@shared/core-utils' 6import { getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
9 cleanupTests, 9 cleanupTests,
@@ -583,7 +583,7 @@ describe('Test video transcoding', function () {
583 } 583 }
584 }) 584 })
585 585
586 it('Should not transcode to an higher bitrate than the original file', async function () { 586 it('Should not transcode to an higher bitrate than the original file but above our low limit', async function () {
587 this.timeout(160_000) 587 this.timeout(160_000)
588 588
589 const newConfig = { 589 const newConfig = {
@@ -622,7 +622,13 @@ describe('Test video transcoding', function () {
622 622
623 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl) 623 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
624 const bitrate = await getVideoFileBitrate(path) 624 const bitrate = await getVideoFileBitrate(path)
625 expect(bitrate, `${path} not below ${60_000}`).to.be.below(60_000) 625
626 const inputBitrate = 60_000
627 const limit = getMinLimitBitrate({ fps: 10, ratio: 1, resolution: r })
628 let belowValue = Math.max(inputBitrate, limit)
629 belowValue += belowValue * 0.20 // Apply 20% margin because bitrate control is not very precise
630
631 expect(bitrate, `${path} not below ${limit}`).to.be.below(belowValue)
626 } 632 }
627 }) 633 })
628 }) 634 })
diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts
index e2cca17f9..0b8629251 100644
--- a/server/tests/cli/print-transcode-command.ts
+++ b/server/tests/cli/print-transcode-command.ts
@@ -2,8 +2,6 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils'
6import { getMaxBitrate } from '@shared/core-utils'
7import { buildAbsoluteFixturePath, CLICommand } from '@shared/extra-utils' 5import { buildAbsoluteFixturePath, CLICommand } from '@shared/extra-utils'
8import { VideoResolution } from '../../../shared/models/videos' 6import { VideoResolution } from '../../../shared/models/videos'
9 7
@@ -13,15 +11,12 @@ describe('Test print transcode jobs', function () {
13 11
14 it('Should print the correct command for each resolution', async function () { 12 it('Should print the correct command for each resolution', async function () {
15 const fixturePath = buildAbsoluteFixturePath('video_short.webm') 13 const fixturePath = buildAbsoluteFixturePath('video_short.webm')
16 const fps = await getVideoFileFPS(fixturePath)
17 const bitrate = await getVideoFileBitrate(fixturePath)
18 14
19 for (const resolution of [ 15 for (const resolution of [
20 VideoResolution.H_720P, 16 VideoResolution.H_720P,
21 VideoResolution.H_1080P 17 VideoResolution.H_1080P
22 ]) { 18 ]) {
23 const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) 19 const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`)
24 const targetBitrate = Math.min(getMaxBitrate({ resolution, fps, ratio: 16 / 9 }), bitrate + (bitrate * 0.3))
25 20
26 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) 21 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`)
27 expect(command).to.includes(`-y -acodec aac -vcodec libx264`) 22 expect(command).to.includes(`-y -acodec aac -vcodec libx264`)
@@ -31,8 +26,8 @@ describe('Test print transcode jobs', function () {
31 expect(command).to.includes('-r 25') 26 expect(command).to.includes('-r 25')
32 expect(command).to.includes('-level:v 3.1') 27 expect(command).to.includes('-level:v 3.1')
33 expect(command).to.includes('-g:v 50') 28 expect(command).to.includes('-g:v 50')
34 expect(command).to.includes(`-maxrate ${targetBitrate}`) 29 expect(command).to.includes(`-maxrate `)
35 expect(command).to.includes(`-bufsize ${targetBitrate * 2}`) 30 expect(command).to.includes(`-bufsize `)
36 } 31 }
37 }) 32 })
38}) 33})