aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-12 13:50:48 +0200
committerChocobozzz <me@florianbigard.com>2021-10-12 13:50:48 +0200
commit10ef089102f2225c5ec3ed426bc612e4f2bc8655 (patch)
treea92171db9114792a363e360bfb645c13d9ea4234 /server
parentc80e458afb63915163467fe9b3b147b3b4e4657d (diff)
parent3c25d37aef66b125e8c66d38b04eb763f1b17bc6 (diff)
downloadPeerTube-10ef089102f2225c5ec3ed426bc612e4f2bc8655.tar.gz
PeerTube-10ef089102f2225c5ec3ed426bc612e4f2bc8655.tar.zst
PeerTube-10ef089102f2225c5ec3ed426bc612e4f2bc8655.zip
Merge branch 'release/3.4.0' into develop
Diffstat (limited to 'server')
-rw-r--r--server/helpers/ffprobe-utils.ts5
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/tests/api/live/live.ts17
-rw-r--r--server/tests/api/videos/video-transcoder.ts5
-rw-r--r--server/tests/cli/print-transcode-command.ts4
5 files changed, 21 insertions, 12 deletions
diff --git a/server/helpers/ffprobe-utils.ts b/server/helpers/ffprobe-utils.ts
index 8381dee84..767f37f9c 100644
--- a/server/helpers/ffprobe-utils.ts
+++ b/server/helpers/ffprobe-utils.ts
@@ -302,7 +302,10 @@ function computeFPS (fpsArg: number, resolution: VideoResolution) {
302 302
303 // Hard FPS limits 303 // Hard FPS limits
304 if (fps > VIDEO_TRANSCODING_FPS.MAX) fps = getClosestFramerateStandard(fps, 'HD_STANDARD') 304 if (fps > VIDEO_TRANSCODING_FPS.MAX) fps = getClosestFramerateStandard(fps, 'HD_STANDARD')
305 else if (fps < VIDEO_TRANSCODING_FPS.MIN) fps = VIDEO_TRANSCODING_FPS.MIN 305
306 if (fps < VIDEO_TRANSCODING_FPS.MIN) {
307 throw new Error(`Cannot compute FPS because ${fps} is lower than our minimum value ${VIDEO_TRANSCODING_FPS.MIN}`)
308 }
306 309
307 return fps 310 return fps
308} 311}
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 2fa0aa7bf..facd3b721 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -346,7 +346,7 @@ const VIEW_LIFETIME = {
346let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour 346let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour
347 347
348const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = { 348const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = {
349 MIN: 10, 349 MIN: 1,
350 STANDARD: [ 24, 25, 30 ], 350 STANDARD: [ 24, 25, 30 ],
351 HD_STANDARD: [ 50, 60 ], 351 HD_STANDARD: [ 50, 60 ],
352 AVERAGE: 30, 352 AVERAGE: 30,
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 5cac3bc4e..0b405dd94 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -517,10 +517,16 @@ describe('Test live', function () {
517 517
518 await waitUntilLivePublishedOnAllServers(servers, liveVideoId) 518 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
519 519
520 const bitrateLimits = { 520 const maxBitrateLimits = {
521 720: 5000 * 1000, // 60FPS 521 720: 6500 * 1000, // 60FPS
522 360: 1100 * 1000, 522 360: 1250 * 1000,
523 240: 600 * 1000 523 240: 700 * 1000
524 }
525
526 const minBitrateLimits = {
527 720: 5500 * 1000,
528 360: 1000 * 1000,
529 240: 550 * 1000
524 } 530 }
525 531
526 for (const server of servers) { 532 for (const server of servers) {
@@ -560,7 +566,8 @@ describe('Test live', function () {
560 const probe = await ffprobePromise(segmentPath) 566 const probe = await ffprobePromise(segmentPath)
561 const videoStream = await getVideoStreamFromFile(segmentPath, probe) 567 const videoStream = await getVideoStreamFromFile(segmentPath, probe)
562 568
563 expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height]) 569 expect(probe.format.bit_rate).to.be.below(maxBitrateLimits[videoStream.height])
570 expect(probe.format.bit_rate).to.be.at.least(minBitrateLimits[videoStream.height])
564 571
565 await makeRawRequest(file.torrentUrl, HttpStatusCode.OK_200) 572 await makeRawRequest(file.torrentUrl, HttpStatusCode.OK_200)
566 await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200) 573 await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 2b49176b2..21609fd82 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -11,7 +11,6 @@ import {
11 doubleFollow, 11 doubleFollow,
12 generateHighBitrateVideo, 12 generateHighBitrateVideo,
13 generateVideoWithFramerate, 13 generateVideoWithFramerate,
14 getFileSize,
15 makeGetRequest, 14 makeGetRequest,
16 PeerTubeServer, 15 PeerTubeServer,
17 setAccessTokensToServers, 16 setAccessTokensToServers,
@@ -617,8 +616,8 @@ describe('Test video transcoding', function () {
617 const file = video.files.find(f => f.resolution.id === r) 616 const file = video.files.find(f => f.resolution.id === r)
618 617
619 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl) 618 const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl)
620 const size = await getFileSize(path) 619 const bitrate = await getVideoFileBitrate(path)
621 expect(size, `${path} not below ${60_000}`).to.be.below(60_000) 620 expect(bitrate, `${path} not below ${60_000}`).to.be.below(60_000)
622 } 621 }
623 }) 622 })
624 }) 623 })
diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts
index e328a6072..e2cca17f9 100644
--- a/server/tests/cli/print-transcode-command.ts
+++ b/server/tests/cli/print-transcode-command.ts
@@ -9,7 +9,7 @@ import { VideoResolution } from '../../../shared/models/videos'
9 9
10const expect = chai.expect 10const expect = chai.expect
11 11
12describe('Test create transcoding jobs', function () { 12describe('Test print transcode jobs', function () {
13 13
14 it('Should print the correct command for each resolution', async function () { 14 it('Should print the correct command for each resolution', async function () {
15 const fixturePath = buildAbsoluteFixturePath('video_short.webm') 15 const fixturePath = buildAbsoluteFixturePath('video_short.webm')
@@ -21,7 +21,7 @@ describe('Test create transcoding jobs', function () {
21 VideoResolution.H_1080P 21 VideoResolution.H_1080P
22 ]) { 22 ]) {
23 const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) 23 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) 24 const targetBitrate = Math.min(getMaxBitrate({ resolution, fps, ratio: 16 / 9 }), bitrate + (bitrate * 0.3))
25 25
26 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) 26 expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`)
27 expect(command).to.includes(`-y -acodec aac -vcodec libx264`) 27 expect(command).to.includes(`-y -acodec aac -vcodec libx264`)