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/videos | |
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/videos')
-rw-r--r-- | server/tests/api/videos/audio-only.ts | 6 | ||||
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 25 |
2 files changed, 17 insertions, 14 deletions
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts index 053b29ca1..294a00112 100644 --- a/server/tests/api/videos/audio-only.ts +++ b/server/tests/api/videos/audio-only.ts | |||
@@ -5,11 +5,11 @@ import * as chai from 'chai' | |||
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' | 6 | import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils' |
7 | import { | 7 | import { |
8 | buildServerDirectory, | ||
8 | cleanupTests, | 9 | cleanupTests, |
9 | doubleFollow, | 10 | doubleFollow, |
10 | flushAndRunMultipleServers, | 11 | flushAndRunMultipleServers, |
11 | getVideo, | 12 | getVideo, |
12 | root, | ||
13 | ServerInfo, | 13 | ServerInfo, |
14 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
15 | uploadVideo, | 15 | uploadVideo, |
@@ -80,8 +80,8 @@ describe('Test audio only video transcoding', function () { | |||
80 | 80 | ||
81 | it('0p transcoded video should not have video', async function () { | 81 | it('0p transcoded video should not have video', async function () { |
82 | const paths = [ | 82 | const paths = [ |
83 | join(root(), 'test' + servers[0].internalServerNumber, 'videos', videoUUID + '-0.mp4'), | 83 | buildServerDirectory(servers[0], join('videos', videoUUID + '-0.mp4')), |
84 | join(root(), 'test' + servers[0].internalServerNumber, 'streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4') | 84 | buildServerDirectory(servers[0], join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')) |
85 | ] | 85 | ] |
86 | 86 | ||
87 | for (const path of paths) { | 87 | for (const path of paths) { |
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 3e336e786..164843d32 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -5,10 +5,10 @@ import * as chai from 'chai' | |||
5 | import { FfprobeData } from 'fluent-ffmpeg' | 5 | import { FfprobeData } from 'fluent-ffmpeg' |
6 | import { omit } from 'lodash' | 6 | import { omit } from 'lodash' |
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | |||
9 | import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' | 8 | import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' |
10 | import { | 9 | import { |
11 | buildAbsoluteFixturePath, | 10 | buildAbsoluteFixturePath, |
11 | buildServerDirectory, | ||
12 | cleanupTests, | 12 | cleanupTests, |
13 | doubleFollow, | 13 | doubleFollow, |
14 | flushAndRunMultipleServers, | 14 | flushAndRunMultipleServers, |
@@ -20,7 +20,6 @@ import { | |||
20 | getVideoFileMetadataUrl, | 20 | getVideoFileMetadataUrl, |
21 | getVideosList, | 21 | getVideosList, |
22 | makeGetRequest, | 22 | makeGetRequest, |
23 | root, | ||
24 | ServerInfo, | 23 | ServerInfo, |
25 | setAccessTokensToServers, | 24 | setAccessTokensToServers, |
26 | updateCustomSubConfig, | 25 | updateCustomSubConfig, |
@@ -136,7 +135,7 @@ describe('Test video transcoding', function () { | |||
136 | 135 | ||
137 | expect(videoDetails.files).to.have.lengthOf(4) | 136 | expect(videoDetails.files).to.have.lengthOf(4) |
138 | 137 | ||
139 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') | 138 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) |
140 | const probe = await getAudioStream(path) | 139 | const probe = await getAudioStream(path) |
141 | 140 | ||
142 | if (probe.audioStream) { | 141 | if (probe.audioStream) { |
@@ -167,7 +166,7 @@ describe('Test video transcoding', function () { | |||
167 | const videoDetails: VideoDetails = res2.body | 166 | const videoDetails: VideoDetails = res2.body |
168 | 167 | ||
169 | expect(videoDetails.files).to.have.lengthOf(4) | 168 | expect(videoDetails.files).to.have.lengthOf(4) |
170 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') | 169 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) |
171 | const probe = await getAudioStream(path) | 170 | const probe = await getAudioStream(path) |
172 | expect(probe).to.not.have.property('audioStream') | 171 | expect(probe).to.not.have.property('audioStream') |
173 | } | 172 | } |
@@ -192,10 +191,13 @@ describe('Test video transcoding', function () { | |||
192 | const videoDetails: VideoDetails = res2.body | 191 | const videoDetails: VideoDetails = res2.body |
193 | 192 | ||
194 | expect(videoDetails.files).to.have.lengthOf(4) | 193 | expect(videoDetails.files).to.have.lengthOf(4) |
194 | |||
195 | const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) | 195 | const fixturePath = buildAbsoluteFixturePath(videoAttributes.fixture) |
196 | const fixtureVideoProbe = await getAudioStream(fixturePath) | 196 | const fixtureVideoProbe = await getAudioStream(fixturePath) |
197 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') | 197 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) |
198 | |||
198 | const videoProbe = await getAudioStream(path) | 199 | const videoProbe = await getAudioStream(path) |
200 | |||
199 | if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { | 201 | if (videoProbe.audioStream && fixtureVideoProbe.audioStream) { |
200 | const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] | 202 | const toOmit = [ 'max_bit_rate', 'duration', 'duration_ts', 'nb_frames', 'start_time', 'start_pts' ] |
201 | expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) | 203 | expect(omit(videoProbe.audioStream, toOmit)).to.be.deep.equal(omit(fixtureVideoProbe.audioStream, toOmit)) |
@@ -231,13 +233,13 @@ describe('Test video transcoding', function () { | |||
231 | expect(videoDetails.files[3].fps).to.be.below(31) | 233 | expect(videoDetails.files[3].fps).to.be.below(31) |
232 | 234 | ||
233 | for (const resolution of [ '240', '360', '480' ]) { | 235 | for (const resolution of [ '240', '360', '480' ]) { |
234 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') | 236 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4')) |
235 | const fps = await getVideoFileFPS(path) | 237 | const fps = await getVideoFileFPS(path) |
236 | 238 | ||
237 | expect(fps).to.be.below(31) | 239 | expect(fps).to.be.below(31) |
238 | } | 240 | } |
239 | 241 | ||
240 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') | 242 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4')) |
241 | const fps = await getVideoFileFPS(path) | 243 | const fps = await getVideoFileFPS(path) |
242 | 244 | ||
243 | expect(fps).to.be.above(58).and.below(62) | 245 | expect(fps).to.be.above(58).and.below(62) |
@@ -325,7 +327,8 @@ describe('Test video transcoding', function () { | |||
325 | const video = res.body.data.find(v => v.name === videoAttributes.name) | 327 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
326 | 328 | ||
327 | for (const resolution of [ '240', '360', '480', '720', '1080' ]) { | 329 | for (const resolution of [ '240', '360', '480', '720', '1080' ]) { |
328 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-' + resolution + '.mp4') | 330 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-' + resolution + '.mp4')) |
331 | |||
329 | const bitrate = await getVideoFileBitrate(path) | 332 | const bitrate = await getVideoFileBitrate(path) |
330 | const fps = await getVideoFileFPS(path) | 333 | const fps = await getVideoFileFPS(path) |
331 | const resolution2 = await getVideoFileResolution(path) | 334 | const resolution2 = await getVideoFileResolution(path) |
@@ -458,13 +461,13 @@ describe('Test video transcoding', function () { | |||
458 | const video = res.body.data.find(v => v.name === videoAttributes.name) | 461 | const video = res.body.data.find(v => v.name === videoAttributes.name) |
459 | 462 | ||
460 | { | 463 | { |
461 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-240.mp4') | 464 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-240.mp4')) |
462 | const fps = await getVideoFileFPS(path) | 465 | const fps = await getVideoFileFPS(path) |
463 | expect(fps).to.be.equal(25) | 466 | expect(fps).to.be.equal(25) |
464 | } | 467 | } |
465 | 468 | ||
466 | { | 469 | { |
467 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', video.uuid + '-720.mp4') | 470 | const path = buildServerDirectory(servers[1], join('videos', video.uuid + '-720.mp4')) |
468 | const fps = await getVideoFileFPS(path) | 471 | const fps = await getVideoFileFPS(path) |
469 | expect(fps).to.be.equal(59) | 472 | expect(fps).to.be.equal(59) |
470 | } | 473 | } |
@@ -513,7 +516,7 @@ describe('Test video transcoding', function () { | |||
513 | await waitJobs(servers) | 516 | await waitJobs(servers) |
514 | 517 | ||
515 | { | 518 | { |
516 | const path = join(root(), 'test' + servers[1].internalServerNumber, 'videos', videoUUID + '-240.mp4') | 519 | const path = buildServerDirectory(servers[1], join('videos', videoUUID + '-240.mp4')) |
517 | const metadata = await getMetadataFromFile(path) | 520 | const metadata = await getMetadataFromFile(path) |
518 | 521 | ||
519 | // expected format properties | 522 | // expected format properties |