Improve generated image quality
|
@ -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
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
BIN
packages/tests/fixtures/custom-preview.jpg
vendored
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.5 KiB |
BIN
packages/tests/fixtures/thumbnail-playlist.jpg
vendored
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
BIN
packages/tests/fixtures/video_short.mp4.jpg
vendored
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
BIN
packages/tests/fixtures/video_short.ogv.jpg
vendored
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.8 KiB |
BIN
packages/tests/fixtures/video_short.webm.jpg
vendored
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 29 KiB |
BIN
packages/tests/fixtures/video_short1.webm.jpg
vendored
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.1 KiB |
BIN
packages/tests/fixtures/video_short2.webm.jpg
vendored
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.4 KiB |
BIN
packages/tests/fixtures/video_short3.webm.jpg
vendored
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
@ -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 })
|
||||
|
|