X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-transcoder.ts;h=21609fd822da0a000c44ef0969fdf3817c2aa28b;hb=9f430a53be016f8db2736d5d8111282660b50f4c;hp=2a09e95bf98e75a50600eaba042be61943f3603b;hpb=83903cb65d531a6b6b91715387493ba8312b264d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 2a09e95bf..21609fd82 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -3,6 +3,7 @@ import 'mocha' import * as chai from 'chai' import { omit } from 'lodash' +import { getMaxBitrate } from '@shared/core-utils' import { buildAbsoluteFixturePath, cleanupTests, @@ -10,15 +11,13 @@ import { doubleFollow, generateHighBitrateVideo, generateVideoWithFramerate, - getFileSize, makeGetRequest, PeerTubeServer, setAccessTokensToServers, waitJobs, webtorrentAdd } from '@shared/extra-utils' -import { getMaxBitrate, HttpStatusCode, VideoResolution, VideoState } from '@shared/models' -import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' +import { HttpStatusCode, VideoState } from '@shared/models' import { canDoQuickTranscode, getAudioStream, @@ -191,15 +190,6 @@ describe('Test video transcoding', function () { it('Should accept and transcode additional extensions', async function () { this.timeout(300_000) - let tempFixturePath: string - - { - tempFixturePath = await generateHighBitrateVideo() - - const bitrate = await getVideoFileBitrate(tempFixturePath) - expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS)) - } - for (const fixture of [ 'video_short.mkv', 'video_short.avi' ]) { const attributes = { name: fixture, @@ -555,14 +545,7 @@ describe('Test video transcoding', function () { it('Should respect maximum bitrate values', async function () { this.timeout(160_000) - let tempFixturePath: string - - { - tempFixturePath = await generateHighBitrateVideo() - - const bitrate = await getVideoFileBitrate(tempFixturePath) - expect(bitrate).to.be.above(getMaxBitrate(VideoResolution.H_1080P, 25, VIDEO_TRANSCODING_FPS)) - } + const tempFixturePath = await generateHighBitrateVideo() const attributes = { name: 'high bitrate video', @@ -586,10 +569,12 @@ describe('Test video transcoding', function () { const bitrate = await getVideoFileBitrate(path) const fps = await getVideoFileFPS(path) - const { videoFileResolution } = await getVideoFileResolution(path) + const dataResolution = await getVideoFileResolution(path) + + expect(resolution).to.equal(resolution) - expect(videoFileResolution).to.equal(resolution) - expect(bitrate).to.be.below(getMaxBitrate(videoFileResolution, fps, VIDEO_TRANSCODING_FPS)) + const maxBitrate = getMaxBitrate({ ...dataResolution, fps }) + expect(bitrate).to.be.below(maxBitrate) } } }) @@ -631,8 +616,8 @@ describe('Test video transcoding', function () { const file = video.files.find(f => f.resolution.id === r) const path = servers[1].servers.buildWebTorrentFilePath(file.fileUrl) - const size = await getFileSize(path) - expect(size, `${path} not below ${60_000}`).to.be.below(60_000) + const bitrate = await getVideoFileBitrate(path) + expect(bitrate, `${path} not below ${60_000}`).to.be.below(60_000) } }) }) @@ -707,7 +692,7 @@ describe('Test video transcoding', function () { describe('Transcoding job queue', function () { it('Should have the appropriate priorities for transcoding jobs', async function () { - const body = await servers[1].jobs.getJobsList({ + const body = await servers[1].jobs.list({ start: 0, count: 100, sort: '-createdAt',