From 0c6c18bb1c804d2e5c81ebe44b2de3107900ae9f Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Sun, 1 Jan 2023 22:09:24 +0100 Subject: [PATCH] Fixing codec path #569 --- .../model/fileprocessing/VideoProcessing.ts | 27 ++++++++++--------- .../fileprocessing/VideoProcessing.spec.ts | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/backend/model/fileprocessing/VideoProcessing.ts b/src/backend/model/fileprocessing/VideoProcessing.ts index 429f4d8b..3e49f7b3 100644 --- a/src/backend/model/fileprocessing/VideoProcessing.ts +++ b/src/backend/model/fileprocessing/VideoProcessing.ts @@ -1,14 +1,11 @@ import * as path from 'path'; -import { constants as fsConstants, promises as fsp } from 'fs'; -import { ITaskExecuter, TaskExecuter } from '../threading/TaskExecuter'; -import { - VideoConverterInput, - VideoConverterWorker, -} from '../threading/VideoConverterWorker'; -import { MetadataLoader } from '../threading/MetadataLoader'; -import { Config } from '../../../common/config/private/Config'; -import { ProjectPath } from '../../ProjectPath'; -import { SupportedFormats } from '../../../common/SupportedFormats'; +import {constants as fsConstants, promises as fsp} from 'fs'; +import {ITaskExecuter, TaskExecuter} from '../threading/TaskExecuter'; +import {VideoConverterInput, VideoConverterWorker,} from '../threading/VideoConverterWorker'; +import {MetadataLoader} from '../threading/MetadataLoader'; +import {Config} from '../../../common/config/private/Config'; +import {ProjectPath} from '../../ProjectPath'; +import {SupportedFormats} from '../../../common/SupportedFormats'; export class VideoProcessing { private static taskQue: ITaskExecuter = @@ -83,7 +80,9 @@ export class VideoProcessing { videoPath, output: { path: outPath, - codec: Config.Media.Video.transcoding.codec, + codec: Config.Media.Video.transcoding.format === 'mp4' ? + Config.Media.Video.transcoding.mp4Codec : + Config.Media.Video.transcoding.webmCodec, format: Config.Media.Video.transcoding.format, crf: Config.Media.Video.transcoding.crf, preset: Config.Media.Video.transcoding.preset, @@ -108,7 +107,7 @@ export class VideoProcessing { const outDir = path.dirname(renderInput.output.path); - await fsp.mkdir(outDir, { recursive: true }); + await fsp.mkdir(outDir, {recursive: true}); await VideoProcessing.taskQue.execute(renderInput); } @@ -121,7 +120,9 @@ export class VideoProcessing { return ( Math.round(Config.Media.Video.transcoding.bitRate / 1024) + 'k' + - Config.Media.Video.transcoding.codec.toString().toLowerCase() + + (Config.Media.Video.transcoding.format === 'mp4' ? + Config.Media.Video.transcoding.mp4Codec : + Config.Media.Video.transcoding.webmCodec).toString().toLowerCase() + Config.Media.Video.transcoding.resolution + '.' + Config.Media.Video.transcoding.format.toLowerCase() diff --git a/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts b/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts index 059f88e0..7a3e18ee 100644 --- a/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts +++ b/test/backend/unit/model/fileprocessing/VideoProcessing.spec.ts @@ -27,7 +27,7 @@ describe('VideoProcessing', () => { } { const convertedPath = VideoProcessing.generateConvertedFilePath(videoPath); - Config.Media.Video.transcoding.codec = 'codec_text' as any; + Config.Media.Video.transcoding.mp4Codec = 'codec_text' as any; expect(await VideoProcessing.isValidConvertedPath(convertedPath)).to.be.false; } {