diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-24 15:22:56 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-25 10:07:51 +0100 |
commit | ca5c612bfdd225433bcc6ace01c8024df3f674ba (patch) | |
tree | 1b722cc346c9079c65338f0792ce7bcd2a20f8a0 /server/tests/api/live | |
parent | 5a547f69d5dc5867e253f7721513479c754b4f15 (diff) | |
download | PeerTube-ca5c612bfdd225433bcc6ace01c8024df3f674ba.tar.gz PeerTube-ca5c612bfdd225433bcc6ace01c8024df3f674ba.tar.zst PeerTube-ca5c612bfdd225433bcc6ace01c8024df3f674ba.zip |
Add live transcoding bit rate tests
Diffstat (limited to 'server/tests/api/live')
-rw-r--r-- | server/tests/api/live/live.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index ac91b6b08..e685be08e 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -3,10 +3,13 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { join } from 'path' | ||
7 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' | ||
6 | import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io' | 8 | import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io' |
7 | import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' | 9 | import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' |
8 | import { | 10 | import { |
9 | addVideoToBlacklist, | 11 | addVideoToBlacklist, |
12 | buildServerDirectory, | ||
10 | checkLiveCleanup, | 13 | checkLiveCleanup, |
11 | checkLiveSegmentHash, | 14 | checkLiveSegmentHash, |
12 | checkResolutionsInMasterPlaylist, | 15 | checkResolutionsInMasterPlaylist, |
@@ -396,10 +399,11 @@ describe('Test live', function () { | |||
396 | this.timeout(60000) | 399 | this.timeout(60000) |
397 | 400 | ||
398 | const resolutions = [ 240, 360, 720 ] | 401 | const resolutions = [ 240, 360, 720 ] |
402 | |||
399 | await updateConf(resolutions) | 403 | await updateConf(resolutions) |
400 | liveVideoId = await createLiveWrapper(true) | 404 | liveVideoId = await createLiveWrapper(true) |
401 | 405 | ||
402 | const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) | 406 | const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm') |
403 | await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) | 407 | await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) |
404 | await waitJobs(servers) | 408 | await waitJobs(servers) |
405 | 409 | ||
@@ -409,6 +413,12 @@ describe('Test live', function () { | |||
409 | 413 | ||
410 | await waitJobs(servers) | 414 | await waitJobs(servers) |
411 | 415 | ||
416 | const bitrateLimits = { | ||
417 | 720: 2800 * 1000, | ||
418 | 360: 780 * 1000, | ||
419 | 240: 320 * 1000 | ||
420 | } | ||
421 | |||
412 | for (const server of servers) { | 422 | for (const server of servers) { |
413 | const resVideo = await getVideo(server.url, liveVideoId) | 423 | const resVideo = await getVideo(server.url, liveVideoId) |
414 | const video: VideoDetails = resVideo.body | 424 | const video: VideoDetails = resVideo.body |
@@ -424,9 +434,17 @@ describe('Test live', function () { | |||
424 | const file = hlsPlaylist.files.find(f => f.resolution.id === resolution) | 434 | const file = hlsPlaylist.files.find(f => f.resolution.id === resolution) |
425 | 435 | ||
426 | expect(file).to.exist | 436 | expect(file).to.exist |
427 | expect(file.fps).to.be.oneOf([ 24, 25 ]) | 437 | expect(file.fps).to.be.approximately(30, 5) |
428 | expect(file.size).to.be.greaterThan(1) | 438 | expect(file.size).to.be.greaterThan(1) |
429 | 439 | ||
440 | const filename = `${video.uuid}-${resolution}-fragmented.mp4` | ||
441 | const segmentPath = buildServerDirectory(servers[0], join('streaming-playlists', 'hls', video.uuid, filename)) | ||
442 | |||
443 | const probe = await ffprobePromise(segmentPath) | ||
444 | const videoStream = await getVideoStreamFromFile(segmentPath, probe) | ||
445 | console.log(videoStream) | ||
446 | expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height]) | ||
447 | |||
430 | await makeRawRequest(file.torrentUrl, 200) | 448 | await makeRawRequest(file.torrentUrl, 200) |
431 | await makeRawRequest(file.fileUrl, 200) | 449 | await makeRawRequest(file.fileUrl, 200) |
432 | } | 450 | } |