From ca5c612bfdd225433bcc6ace01c8024df3f674ba Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 24 Nov 2020 15:22:56 +0100 Subject: Add live transcoding bit rate tests --- server/tests/api/live/live.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'server/tests/api/live') 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 @@ import 'mocha' import * as chai from 'chai' import { FfmpegCommand } from 'fluent-ffmpeg' +import { join } from 'path' +import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io' import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' import { addVideoToBlacklist, + buildServerDirectory, checkLiveCleanup, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, @@ -396,10 +399,11 @@ describe('Test live', function () { this.timeout(60000) const resolutions = [ 240, 360, 720 ] + await updateConf(resolutions) liveVideoId = await createLiveWrapper(true) - const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId) + const command = await sendRTMPStreamInVideo(servers[0].url, servers[0].accessToken, liveVideoId, 'video_short2.webm') await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoId) await waitJobs(servers) @@ -409,6 +413,12 @@ describe('Test live', function () { await waitJobs(servers) + const bitrateLimits = { + 720: 2800 * 1000, + 360: 780 * 1000, + 240: 320 * 1000 + } + for (const server of servers) { const resVideo = await getVideo(server.url, liveVideoId) const video: VideoDetails = resVideo.body @@ -424,9 +434,17 @@ describe('Test live', function () { const file = hlsPlaylist.files.find(f => f.resolution.id === resolution) expect(file).to.exist - expect(file.fps).to.be.oneOf([ 24, 25 ]) + expect(file.fps).to.be.approximately(30, 5) expect(file.size).to.be.greaterThan(1) + const filename = `${video.uuid}-${resolution}-fragmented.mp4` + const segmentPath = buildServerDirectory(servers[0], join('streaming-playlists', 'hls', video.uuid, filename)) + + const probe = await ffprobePromise(segmentPath) + const videoStream = await getVideoStreamFromFile(segmentPath, probe) + console.log(videoStream) + expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height]) + await makeRawRequest(file.torrentUrl, 200) await makeRawRequest(file.fileUrl, 200) } -- cgit v1.2.3