From 8c3f87ae868efa48bc03b28594e9446f33130861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Le=20Calvar?= Date: Tue, 16 May 2023 22:22:52 +0200 Subject: [PATCH] change quality option to newer ffmpeg --- src/main.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main.ts b/src/main.ts index e1246b2..ad1e8a4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,10 +6,10 @@ let logger : Logger let transcodingManager : PluginTranscodingManager const DEFAULT_HARDWARE_DECODE : boolean = false -const DEFAULT_COMPRESSION_LEVEL : number = 3 +const DEFAULT_QUALITY : number = -1 let hardwareDecode : boolean = DEFAULT_HARDWARE_DECODE -let compressionLevel : number = DEFAULT_COMPRESSION_LEVEL +let quality : number = DEFAULT_QUALITY let baseBitrates : Map = new Map([ [VideoResolution.H_NOVIDEO, 64 * 1000], @@ -42,7 +42,7 @@ export async function register(options :RegisterServerOptions) { // Get stored data from the database, default to constants if not found hardwareDecode = await options.storageManager.getData('hardware-decode') == "true" // ?? DEFAULT_HARDWARE_DECODE // not needed, since undefined == "true" -> false - compressionLevel = parseInt(await options.storageManager.getData('compression-level')) ?? DEFAULT_COMPRESSION_LEVEL + quality = parseInt(await options.storageManager.getData('compression-level')) ?? DEFAULT_QUALITY for (const [resolution, bitrate] of baseBitrates) { const key = `base-bitrate-${resolution}` @@ -53,7 +53,7 @@ export async function register(options :RegisterServerOptions) { } logger.info(`Hardware decode: ${hardwareDecode}`) - logger.info(`Compression level: ${compressionLevel}`) + logger.info(`Quality: ${quality}`) options.registerSetting({ name: 'hardware-decode', @@ -67,11 +67,12 @@ export async function register(options :RegisterServerOptions) { private: false }) options.registerSetting({ - name: 'compression-level', - label: 'Compression level', + name: 'quality', + label: 'Quality', type: 'select', options: [ + { label: 'Automatic', value: '-1' }, { label: '1', value: '1' }, { label: '2', value: '2' }, { label: '3', value: '3' }, @@ -83,7 +84,7 @@ export async function register(options :RegisterServerOptions) { descriptionHTML: 'This parameter controls the speed / quality tradeoff. Lower values mean better quality but slower encoding. Higher values mean faster encoding but lower quality. This setting is hardware dependent, you may need to experiment to find the best value for your hardware. Some hardware may have less than 7 levels of compression.', - default: compressionLevel.toString(), + default: quality.toString(), private: false }) @@ -112,7 +113,7 @@ export async function register(options :RegisterServerOptions) { options.settingsManager.onSettingsChange(async (settings) => { hardwareDecode = settings['hardware-decode'] as boolean - compressionLevel = parseInt(settings['compression-level'] as string) || DEFAULT_COMPRESSION_LEVEL + quality = parseInt(settings['quality'] as string) || DEFAULT_QUALITY for (const [resolution, bitrate] of baseBitrates) { const key = `base-bitrate-${resolution}` @@ -124,7 +125,7 @@ export async function register(options :RegisterServerOptions) { } logger.info(`New hardware decode: ${hardwareDecode}`) - logger.info(`New compression level: ${compressionLevel}`) + logger.info(`New quality: ${quality}`) }) } @@ -187,7 +188,7 @@ async function vodBuilder(params: EncoderOptionsBuilderParams) : Promise