X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fcli%2Fprint-transcode-command.ts;h=e328a60721788d192df8384f1bb12bee20203443;hb=679c12e69c9f3a2d003ee3abe8b8da49f25b2bd3;hp=4a7988d4deaa4ecf823b485269fdbe784ad39753;hpb=7185dab3ff509cec9f03a15d826625b5a1bd0ada;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts index 4a7988d4d..e328a6072 100644 --- a/server/tests/cli/print-transcode-command.ts +++ b/server/tests/cli/print-transcode-command.ts @@ -2,16 +2,17 @@ import 'mocha' import * as chai from 'chai' -import { execCLI } from '../../../shared/extra-utils' -import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos' -import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils' +import { getMaxBitrate } from '@shared/core-utils' +import { buildAbsoluteFixturePath, CLICommand } from '@shared/extra-utils' +import { VideoResolution } from '../../../shared/models/videos' const expect = chai.expect describe('Test create transcoding jobs', function () { + it('Should print the correct command for each resolution', async function () { - const fixturePath = 'server/tests/fixtures/video_short.webm' + const fixturePath = buildAbsoluteFixturePath('video_short.webm') const fps = await getVideoFileFPS(fixturePath) const bitrate = await getVideoFileBitrate(fixturePath) @@ -19,10 +20,11 @@ describe('Test create transcoding jobs', function () { VideoResolution.H_720P, VideoResolution.H_1080P ]) { - const command = await execCLI(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) - const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate) + const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) + const targetBitrate = Math.min(getMaxBitrate({ resolution, fps, ratio: 16 / 9 }), bitrate) - expect(command).to.includes(`-y -acodec aac -vcodec libx264 -filter:v scale=w=trunc(oh*a/2)*2:h=${resolution}`) + expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) + expect(command).to.includes(`-y -acodec aac -vcodec libx264`) expect(command).to.includes('-f mp4') expect(command).to.includes('-movflags faststart') expect(command).to.includes('-b:a 256k')