]>
Commit | Line | Data |
---|---|---|
7185dab3 RK |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
5 | import { execCLI } from '../../../shared/extra-utils' | |
6 | import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos' | |
7 | import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' | |
8 | import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils' | |
9 | ||
10 | const expect = chai.expect | |
11 | ||
12 | describe('Test create transcoding jobs', function () { | |
13 | it('Should print the correct command for each resolution', async function () { | |
14 | const fixturePath = 'server/tests/fixtures/video_short.webm' | |
15 | const fps = await getVideoFileFPS(fixturePath) | |
16 | const bitrate = await getVideoFileBitrate(fixturePath) | |
17 | ||
18 | for (const resolution of [ | |
19 | VideoResolution.H_720P, | |
20 | VideoResolution.H_1080P | |
21 | ]) { | |
22 | const command = await execCLI(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) | |
23 | const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate) | |
24 | ||
21c917b3 C |
25 | expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) |
26 | expect(command).to.includes(`-y -acodec aac -vcodec libx264`) | |
7185dab3 RK |
27 | expect(command).to.includes('-f mp4') |
28 | expect(command).to.includes('-movflags faststart') | |
29 | expect(command).to.includes('-b:a 256k') | |
30 | expect(command).to.includes('-r 25') | |
31 | expect(command).to.includes('-level:v 3.1') | |
32 | expect(command).to.includes('-g:v 50') | |
33 | expect(command).to.includes(`-maxrate ${targetBitrate}`) | |
34 | expect(command).to.includes(`-bufsize ${targetBitrate * 2}`) | |
35 | } | |
36 | }) | |
37 | }) |