diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/tests/cli/index.ts | 1 | ||||
-rw-r--r-- | server/tests/cli/print-transcode-command.ts | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/server/tests/cli/index.ts b/server/tests/cli/index.ts index 029cd5196..242589010 100644 --- a/server/tests/cli/index.ts +++ b/server/tests/cli/index.ts | |||
@@ -4,6 +4,7 @@ import './create-transcoding-job' | |||
4 | import './optimize-old-videos' | 4 | import './optimize-old-videos' |
5 | import './peertube' | 5 | import './peertube' |
6 | import './plugins' | 6 | import './plugins' |
7 | import './print-transcode-command' | ||
7 | import './prune-storage' | 8 | import './prune-storage' |
8 | import './reset-password' | 9 | import './reset-password' |
9 | import './update-host' | 10 | import './update-host' |
diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts new file mode 100644 index 000000000..4a7988d4d --- /dev/null +++ b/server/tests/cli/print-transcode-command.ts | |||
@@ -0,0 +1,36 @@ | |||
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 | |||
25 | expect(command).to.includes(`-y -acodec aac -vcodec libx264 -filter:v scale=w=trunc(oh*a/2)*2:h=${resolution}`) | ||
26 | expect(command).to.includes('-f mp4') | ||
27 | expect(command).to.includes('-movflags faststart') | ||
28 | expect(command).to.includes('-b:a 256k') | ||
29 | expect(command).to.includes('-r 25') | ||
30 | expect(command).to.includes('-level:v 3.1') | ||
31 | expect(command).to.includes('-g:v 50') | ||
32 | expect(command).to.includes(`-maxrate ${targetBitrate}`) | ||
33 | expect(command).to.includes(`-bufsize ${targetBitrate * 2}`) | ||
34 | } | ||
35 | }) | ||
36 | }) | ||