aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-06 10:39:40 +0200
committerChocobozzz <me@florianbigard.com>2021-08-06 10:39:40 +0200
commitc826f34a45757b324a20f71665b44ed10e6953b5 (patch)
treeff29bdff8b4519bbdbbcd3aa0d68521ce2b06ff5 /server/tests
parent421ff4618da64f0849353383f690a014024c40da (diff)
downloadPeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.tar.gz
PeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.tar.zst
PeerTube-c826f34a45757b324a20f71665b44ed10e6953b5.zip
Limit live bitrate
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/live.ts4
-rw-r--r--server/tests/api/live/live.ts40
2 files changed, 36 insertions, 8 deletions
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 700b4724d..8e1d655d4 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -417,7 +417,7 @@ describe('Test video lives API validator', function () {
417 417
418 const live = await command.get({ videoId: video.id }) 418 const live = await command.get({ videoId: video.id })
419 419
420 const ffmpegCommand = sendRTMPStream(live.rtmpUrl, live.streamKey) 420 const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey })
421 421
422 await command.waitUntilPublished({ videoId: video.id }) 422 await command.waitUntilPublished({ videoId: video.id })
423 await command.update({ videoId: video.id, fields: {}, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 423 await command.update({ videoId: video.id, fields: {}, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
@@ -430,7 +430,7 @@ describe('Test video lives API validator', function () {
430 430
431 const live = await command.get({ videoId: video.id }) 431 const live = await command.get({ videoId: video.id })
432 432
433 const ffmpegCommand = sendRTMPStream(live.rtmpUrl, live.streamKey) 433 const ffmpegCommand = sendRTMPStream({ rtmpBaseUrl: live.rtmpUrl, streamKey: live.streamKey })
434 434
435 await command.waitUntilPublished({ videoId: video.id }) 435 await command.waitUntilPublished({ videoId: video.id })
436 436
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index d555cff19..4095cdb1c 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { basename, join } from 'path' 5import { basename, join } from 'path'
6import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' 6import { ffprobePromise, getVideoFileBitrate, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
7import { 7import {
8 checkLiveCleanupAfterSave, 8 checkLiveCleanupAfterSave,
9 checkLiveSegmentHash, 9 checkLiveSegmentHash,
@@ -302,21 +302,21 @@ describe('Test live', function () {
302 302
303 liveVideo = await createLiveWrapper() 303 liveVideo = await createLiveWrapper()
304 304
305 const command = sendRTMPStream(rtmpUrl + '/bad-live', liveVideo.streamKey) 305 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/bad-live', streamKey: liveVideo.streamKey })
306 await testFfmpegStreamError(command, true) 306 await testFfmpegStreamError(command, true)
307 }) 307 })
308 308
309 it('Should not allow a stream without the appropriate stream key', async function () { 309 it('Should not allow a stream without the appropriate stream key', async function () {
310 this.timeout(60000) 310 this.timeout(60000)
311 311
312 const command = sendRTMPStream(rtmpUrl + '/live', 'bad-stream-key') 312 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: 'bad-stream-key' })
313 await testFfmpegStreamError(command, true) 313 await testFfmpegStreamError(command, true)
314 }) 314 })
315 315
316 it('Should succeed with the correct params', async function () { 316 it('Should succeed with the correct params', async function () {
317 this.timeout(60000) 317 this.timeout(60000)
318 318
319 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 319 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey })
320 await testFfmpegStreamError(command, false) 320 await testFfmpegStreamError(command, false)
321 }) 321 })
322 322
@@ -340,7 +340,7 @@ describe('Test live', function () {
340 340
341 await servers[0].blacklist.add({ videoId: liveVideo.uuid }) 341 await servers[0].blacklist.add({ videoId: liveVideo.uuid })
342 342
343 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 343 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey })
344 await testFfmpegStreamError(command, true) 344 await testFfmpegStreamError(command, true)
345 }) 345 })
346 346
@@ -351,7 +351,7 @@ describe('Test live', function () {
351 351
352 await servers[0].videos.remove({ id: liveVideo.uuid }) 352 await servers[0].videos.remove({ id: liveVideo.uuid })
353 353
354 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 354 const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey })
355 await testFfmpegStreamError(command, true) 355 await testFfmpegStreamError(command, true)
356 }) 356 })
357 }) 357 })
@@ -468,6 +468,34 @@ describe('Test live', function () {
468 await stopFfmpeg(ffmpegCommand) 468 await stopFfmpeg(ffmpegCommand)
469 }) 469 })
470 470
471 it('Should correctly set the appropriate bitrate depending on the input', async function () {
472 this.timeout(120000)
473
474 liveVideoId = await createLiveWrapper(false)
475
476 const ffmpegCommand = await commands[0].sendRTMPStreamInVideo({
477 videoId: liveVideoId,
478 fixtureName: 'video_short.mp4',
479 copyCodecs: true
480 })
481 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
482 await waitJobs(servers)
483
484 const video = await servers[0].videos.get({ id: liveVideoId })
485
486 const masterPlaylist = video.streamingPlaylists[0].playlistUrl
487 const probe = await ffprobePromise(masterPlaylist)
488
489 const bitrates = probe.streams.map(s => parseInt(s.tags.variant_bitrate))
490 for (const bitrate of bitrates) {
491 expect(bitrate).to.exist
492 expect(isNaN(bitrate)).to.be.false
493 expect(bitrate).to.be.below(61_000_000) // video_short.mp4 bitrate
494 }
495
496 await stopFfmpeg(ffmpegCommand)
497 })
498
471 it('Should enable transcoding with some resolutions and correctly save them', async function () { 499 it('Should enable transcoding with some resolutions and correctly save them', async function () {
472 this.timeout(200000) 500 this.timeout(200000)
473 501