diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-12 13:50:48 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-12 13:50:48 +0200 |
commit | 10ef089102f2225c5ec3ed426bc612e4f2bc8655 (patch) | |
tree | a92171db9114792a363e360bfb645c13d9ea4234 | |
parent | c80e458afb63915163467fe9b3b147b3b4e4657d (diff) | |
parent | 3c25d37aef66b125e8c66d38b04eb763f1b17bc6 (diff) | |
download | PeerTube-10ef089102f2225c5ec3ed426bc612e4f2bc8655.tar.gz PeerTube-10ef089102f2225c5ec3ed426bc612e4f2bc8655.tar.zst PeerTube-10ef089102f2225c5ec3ed426bc612e4f2bc8655.zip |
Merge branch 'release/3.4.0' into develop
-rw-r--r-- | client/src/app/+videos/+video-edit/video-add.component.ts | 1 | ||||
-rw-r--r-- | server/helpers/ffprobe-utils.ts | 5 | ||||
-rw-r--r-- | server/initializers/constants.ts | 2 | ||||
-rw-r--r-- | server/tests/api/live/live.ts | 17 | ||||
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 5 | ||||
-rw-r--r-- | server/tests/cli/print-transcode-command.ts | 4 | ||||
-rw-r--r-- | shared/core-utils/videos/bitrate.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/mock-servers/mock-instances-index.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/mock-servers/mock-object-storage.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/mock-servers/mock-plugin-blocklist.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/mock-servers/mock-proxy.ts | 2 |
12 files changed, 28 insertions, 18 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos/+video-edit/video-add.component.ts index bcb2fc4fa..25203de1b 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.ts +++ b/client/src/app/+videos/+video-edit/video-add.component.ts | |||
@@ -144,6 +144,7 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { | |||
144 | } | 144 | } |
145 | 145 | ||
146 | canDeactivate (): { canDeactivate: boolean, text?: string} { | 146 | canDeactivate (): { canDeactivate: boolean, text?: string} { |
147 | if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate() | ||
147 | if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate() | 148 | if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate() |
148 | if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate() | 149 | if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate() |
149 | if (this.secondStepType === 'go-live') return this.videoGoLive.canDeactivate() | 150 | if (this.secondStepType === 'go-live') return this.videoGoLive.canDeactivate() |
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 = { | |||
346 | let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour | 346 | let CONTACT_FORM_LIFETIME = 60000 * 60 // 1 hour |
347 | 347 | ||
348 | const VIDEO_TRANSCODING_FPS: VideoTranscodingFPS = { | 348 | const 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 | ||
10 | const expect = chai.expect | 10 | const expect = chai.expect |
11 | 11 | ||
12 | describe('Test create transcoding jobs', function () { | 12 | describe('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`) |
diff --git a/shared/core-utils/videos/bitrate.ts b/shared/core-utils/videos/bitrate.ts index 3d4e47906..a6712f8a4 100644 --- a/shared/core-utils/videos/bitrate.ts +++ b/shared/core-utils/videos/bitrate.ts | |||
@@ -78,7 +78,7 @@ function calculateBitrate (options: { | |||
78 | 78 | ||
79 | for (const toTestResolution of resolutionsOrder) { | 79 | for (const toTestResolution of resolutionsOrder) { |
80 | if (toTestResolution <= resolution) { | 80 | if (toTestResolution <= resolution) { |
81 | return resolution * resolution * ratio * fps * bitPerPixel[toTestResolution] | 81 | return Math.floor(resolution * resolution * ratio * fps * bitPerPixel[toTestResolution]) |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
diff --git a/shared/extra-utils/mock-servers/mock-instances-index.ts b/shared/extra-utils/mock-servers/mock-instances-index.ts index 2aabef9d2..5baec00de 100644 --- a/shared/extra-utils/mock-servers/mock-instances-index.ts +++ b/shared/extra-utils/mock-servers/mock-instances-index.ts | |||
@@ -29,7 +29,7 @@ export class MockInstancesIndex { | |||
29 | }) | 29 | }) |
30 | }) | 30 | }) |
31 | 31 | ||
32 | const port = 42101 + randomInt(1, 100) | 32 | const port = 42000 + randomInt(1, 1000) |
33 | app.listen(port, () => res(port)) | 33 | app.listen(port, () => res(port)) |
34 | }) | 34 | }) |
35 | } | 35 | } |
diff --git a/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts b/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts index 5106fc66a..79be31f61 100644 --- a/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts +++ b/shared/extra-utils/mock-servers/mock-joinpeertube-versions.ts | |||
@@ -22,7 +22,7 @@ export class MockJoinPeerTubeVersions { | |||
22 | }) | 22 | }) |
23 | }) | 23 | }) |
24 | 24 | ||
25 | const port = 42201 + randomInt(1, 100) | 25 | const port = 43000 + randomInt(1, 1000) |
26 | app.listen(port, () => res(port)) | 26 | app.listen(port, () => res(port)) |
27 | }) | 27 | }) |
28 | } | 28 | } |
diff --git a/shared/extra-utils/mock-servers/mock-object-storage.ts b/shared/extra-utils/mock-servers/mock-object-storage.ts index b6071b2f2..144f2819d 100644 --- a/shared/extra-utils/mock-servers/mock-object-storage.ts +++ b/shared/extra-utils/mock-servers/mock-object-storage.ts | |||
@@ -32,7 +32,7 @@ export class MockObjectStorage { | |||
32 | ) | 32 | ) |
33 | }) | 33 | }) |
34 | 34 | ||
35 | const port = 42301 + randomInt(1, 100) | 35 | const port = 44000 + randomInt(1, 1000) |
36 | this.server = app.listen(port, () => res(port)) | 36 | this.server = app.listen(port, () => res(port)) |
37 | }) | 37 | }) |
38 | } | 38 | } |
diff --git a/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts b/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts index 6a71532b5..344d4bdbb 100644 --- a/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts +++ b/shared/extra-utils/mock-servers/mock-plugin-blocklist.ts | |||
@@ -23,7 +23,7 @@ export class MockBlocklist { | |||
23 | return res.json(this.body) | 23 | return res.json(this.body) |
24 | }) | 24 | }) |
25 | 25 | ||
26 | const port = 42201 + randomInt(1, 100) | 26 | const port = 45000 + randomInt(1, 1000) |
27 | this.server = app.listen(port, () => res(port)) | 27 | this.server = app.listen(port, () => res(port)) |
28 | }) | 28 | }) |
29 | } | 29 | } |
diff --git a/shared/extra-utils/mock-servers/mock-proxy.ts b/shared/extra-utils/mock-servers/mock-proxy.ts index f955d3f9e..8583250f3 100644 --- a/shared/extra-utils/mock-servers/mock-proxy.ts +++ b/shared/extra-utils/mock-servers/mock-proxy.ts | |||
@@ -9,7 +9,7 @@ class MockProxy { | |||
9 | 9 | ||
10 | initialize () { | 10 | initialize () { |
11 | return new Promise<number>(res => { | 11 | return new Promise<number>(res => { |
12 | const port = 42501 + randomInt(1, 100) | 12 | const port = 46000 + randomInt(1, 1000) |
13 | 13 | ||
14 | this.server = proxy(createServer()) | 14 | this.server = proxy(createServer()) |
15 | this.server.listen(port, () => res(port)) | 15 | this.server.listen(port, () => res(port)) |