change quality option to newer ffmpeg
This commit is contained in:
parent
3a0f80ef13
commit
8c3f87ae86
23
src/main.ts
23
src/main.ts
@ -6,10 +6,10 @@ let logger : Logger
|
|||||||
let transcodingManager : PluginTranscodingManager
|
let transcodingManager : PluginTranscodingManager
|
||||||
|
|
||||||
const DEFAULT_HARDWARE_DECODE : boolean = false
|
const DEFAULT_HARDWARE_DECODE : boolean = false
|
||||||
const DEFAULT_COMPRESSION_LEVEL : number = 3
|
const DEFAULT_QUALITY : number = -1
|
||||||
|
|
||||||
let hardwareDecode : boolean = DEFAULT_HARDWARE_DECODE
|
let hardwareDecode : boolean = DEFAULT_HARDWARE_DECODE
|
||||||
let compressionLevel : number = DEFAULT_COMPRESSION_LEVEL
|
let quality : number = DEFAULT_QUALITY
|
||||||
|
|
||||||
let baseBitrates : Map<VideoResolution, number> = new Map([
|
let baseBitrates : Map<VideoResolution, number> = new Map([
|
||||||
[VideoResolution.H_NOVIDEO, 64 * 1000],
|
[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
|
// 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
|
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) {
|
for (const [resolution, bitrate] of baseBitrates) {
|
||||||
const key = `base-bitrate-${resolution}`
|
const key = `base-bitrate-${resolution}`
|
||||||
@ -53,7 +53,7 @@ export async function register(options :RegisterServerOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Hardware decode: ${hardwareDecode}`)
|
logger.info(`Hardware decode: ${hardwareDecode}`)
|
||||||
logger.info(`Compression level: ${compressionLevel}`)
|
logger.info(`Quality: ${quality}`)
|
||||||
|
|
||||||
options.registerSetting({
|
options.registerSetting({
|
||||||
name: 'hardware-decode',
|
name: 'hardware-decode',
|
||||||
@ -67,11 +67,12 @@ export async function register(options :RegisterServerOptions) {
|
|||||||
private: false
|
private: false
|
||||||
})
|
})
|
||||||
options.registerSetting({
|
options.registerSetting({
|
||||||
name: 'compression-level',
|
name: 'quality',
|
||||||
label: 'Compression level',
|
label: 'Quality',
|
||||||
|
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: [
|
options: [
|
||||||
|
{ label: 'Automatic', value: '-1' },
|
||||||
{ label: '1', value: '1' },
|
{ label: '1', value: '1' },
|
||||||
{ label: '2', value: '2' },
|
{ label: '2', value: '2' },
|
||||||
{ label: '3', value: '3' },
|
{ 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.',
|
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
|
private: false
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ export async function register(options :RegisterServerOptions) {
|
|||||||
|
|
||||||
options.settingsManager.onSettingsChange(async (settings) => {
|
options.settingsManager.onSettingsChange(async (settings) => {
|
||||||
hardwareDecode = settings['hardware-decode'] as boolean
|
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) {
|
for (const [resolution, bitrate] of baseBitrates) {
|
||||||
const key = `base-bitrate-${resolution}`
|
const key = `base-bitrate-${resolution}`
|
||||||
@ -124,7 +125,7 @@ export async function register(options :RegisterServerOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`New hardware decode: ${hardwareDecode}`)
|
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<Encoder
|
|||||||
},
|
},
|
||||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
outputOptions: [
|
outputOptions: [
|
||||||
`-compression_level ${compressionLevel}`,
|
`-quality ${quality}`,
|
||||||
`-b:v${streamSuffix} ${targetBitrate}`,
|
`-b:v${streamSuffix} ${targetBitrate}`,
|
||||||
`-bufsize ${targetBitrate * 2}`
|
`-bufsize ${targetBitrate * 2}`
|
||||||
]
|
]
|
||||||
@ -220,7 +221,7 @@ async function liveBuilder(params: EncoderOptionsBuilderParams) : Promise<Encode
|
|||||||
},
|
},
|
||||||
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
inputOptions: shouldInitVaapi ? buildInitOptions() : [],
|
||||||
outputOptions: [
|
outputOptions: [
|
||||||
`-compression_level ${compressionLevel}`,
|
`-quality ${quality}`,
|
||||||
`-r:v${streamSuffix} ${fps}`,
|
`-r:v${streamSuffix} ${fps}`,
|
||||||
`-profile:v${streamSuffix} high`,
|
`-profile:v${streamSuffix} high`,
|
||||||
`-level:v${streamSuffix} 3.1`,
|
`-level:v${streamSuffix} 3.1`,
|
||||||
|
Loading…
Reference in New Issue
Block a user