diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-06 13:35:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-06 14:13:26 +0200 |
commit | 679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3 (patch) | |
tree | 03abf589275db05e5b1fa1c89f57049cd807324a /server/tests/cli/print-transcode-command.ts | |
parent | c826f34a45757b324a20f71665b44ed10e6953b5 (diff) | |
download | PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.gz PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.tar.zst PeerTube-679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3.zip |
Improve target bitrate calculation
Diffstat (limited to 'server/tests/cli/print-transcode-command.ts')
-rw-r--r-- | server/tests/cli/print-transcode-command.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts index 3a7969e68..e328a6072 100644 --- a/server/tests/cli/print-transcode-command.ts +++ b/server/tests/cli/print-transcode-command.ts | |||
@@ -3,16 +3,16 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils' | 5 | import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils' |
6 | import { CLICommand } from '@shared/extra-utils' | 6 | import { getMaxBitrate } from '@shared/core-utils' |
7 | import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos' | 7 | import { buildAbsoluteFixturePath, CLICommand } from '@shared/extra-utils' |
8 | import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' | 8 | import { VideoResolution } from '../../../shared/models/videos' |
9 | 9 | ||
10 | const expect = chai.expect | 10 | const expect = chai.expect |
11 | 11 | ||
12 | describe('Test create transcoding jobs', function () { | 12 | describe('Test create transcoding jobs', function () { |
13 | 13 | ||
14 | it('Should print the correct command for each resolution', async function () { | 14 | it('Should print the correct command for each resolution', async function () { |
15 | const fixturePath = 'server/tests/fixtures/video_short.webm' | 15 | const fixturePath = buildAbsoluteFixturePath('video_short.webm') |
16 | const fps = await getVideoFileFPS(fixturePath) | 16 | const fps = await getVideoFileFPS(fixturePath) |
17 | const bitrate = await getVideoFileBitrate(fixturePath) | 17 | const bitrate = await getVideoFileBitrate(fixturePath) |
18 | 18 | ||
@@ -21,7 +21,7 @@ describe('Test create transcoding jobs', function () { | |||
21 | VideoResolution.H_1080P | 21 | VideoResolution.H_1080P |
22 | ]) { | 22 | ]) { |
23 | const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) | 23 | const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) |
24 | const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate) | 24 | const targetBitrate = Math.min(getMaxBitrate({ resolution, fps, ratio: 16 / 9 }), bitrate) |
25 | 25 | ||
26 | expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) | 26 | expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) |
27 | expect(command).to.includes(`-y -acodec aac -vcodec libx264`) | 27 | expect(command).to.includes(`-y -acodec aac -vcodec libx264`) |