Improve generated image quality

pull/6266/head
Chocobozzz 2024-02-26 10:37:44 +01:00
parent 1abf74e464
commit fb2dc40858
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
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

View File

@ -380,7 +380,7 @@ async function generateImageFromVideoFile (options: {
try {
const framesToAnalyze = CONFIG.THUMBNAILS.GENERATION_FROM_VIDEO.FRAMES_TO_ANALYZE
await generateThumbnailFromVideo({ fromPath, output: pendingImagePath, framesToAnalyze, ffprobe })
await generateThumbnailFromVideo({ fromPath, output: pendingImagePath, framesToAnalyze, ffprobe, scale: size })
const destination = join(folder, imageName)
await processImageFromWorker({ path: pendingImagePath, destination, newSize: size })