Improve generated image quality

This commit is contained in:
Chocobozzz
2024-02-26 10:37:44 +01:00
parent 1abf74e464
commit fb2dc40858
12 changed files with 18 additions and 3 deletions

View File

@@ -42,6 +42,10 @@ export class FFmpegImage {
fromPath: string
output: string
framesToAnalyze: number
scale?: {
width: number
height: number
}
ffprobe?: FfprobeData
}) {
const { fromPath, ffprobe } = options
@@ -69,14 +73,25 @@ export class FFmpegImage {
fromPath: string
output: string
framesToAnalyze: number
scale?: {
width: number
height: number
}
}) {
const { fromPath, output, framesToAnalyze } = options
const { fromPath, output, framesToAnalyze, scale } = options
return this.commandWrapper.buildCommand(fromPath)
const command = this.commandWrapper.buildCommand(fromPath)
.videoFilter('thumbnail=' + framesToAnalyze)
.outputOption('-frames:v 1')
.outputOption('-q:v 5')
.outputOption('-abort_on empty_output')
.output(output)
if (scale) {
command.videoFilter(`scale=${scale.width}x${scale.height}:force_original_aspect_ratio=decrease`)
}
return command
}
// ---------------------------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB