Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Improve generated image quality

Chocobozzzfb2dc408585d
diff --git a/packages/ffmpeg/src/ffmpeg-images.ts b/packages/ffmpeg/src/ffmpeg-images.ts
index f9f352e3c2..296cd10fba 100644
--- a/packages/ffmpeg/src/ffmpeg-images.ts
+++ b/packages/ffmpeg/src/ffmpeg-images.ts
@@ -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
}
// ---------------------------------------------------------------------------
diff --git a/packages/tests/fixtures/custom-preview.jpg b/packages/tests/fixtures/custom-preview.jpg
index 5a039d8307..a070c2bc50 100644
Binary files a/packages/tests/fixtures/custom-preview.jpg and b/packages/tests/fixtures/custom-preview.jpg differ
diff --git a/packages/tests/fixtures/custom-thumbnail-from-preview.jpg b/packages/tests/fixtures/custom-thumbnail-from-preview.jpg
index fe8545b481..8238f4b8ce 100644
Binary files a/packages/tests/fixtures/custom-thumbnail-from-preview.jpg and b/packages/tests/fixtures/custom-thumbnail-from-preview.jpg differ
diff --git a/packages/tests/fixtures/thumbnail-playlist.jpg b/packages/tests/fixtures/thumbnail-playlist.jpg
index cc51fc7839..061f19f70a 100644
Binary files a/packages/tests/fixtures/thumbnail-playlist.jpg and b/packages/tests/fixtures/thumbnail-playlist.jpg differ
diff --git a/packages/tests/fixtures/video_short.mp4.jpg b/packages/tests/fixtures/video_short.mp4.jpg
index 2ff0144395..1b8ed917a9 100644
Binary files a/packages/tests/fixtures/video_short.mp4.jpg and b/packages/tests/fixtures/video_short.mp4.jpg differ
diff --git a/packages/tests/fixtures/video_short.ogv.jpg b/packages/tests/fixtures/video_short.ogv.jpg
index 4fcb8fbd1d..a4c514d132 100644
Binary files a/packages/tests/fixtures/video_short.ogv.jpg and b/packages/tests/fixtures/video_short.ogv.jpg differ
diff --git a/packages/tests/fixtures/video_short.webm.jpg b/packages/tests/fixtures/video_short.webm.jpg
index cc51fc7839..061f19f70a 100644
Binary files a/packages/tests/fixtures/video_short.webm.jpg and b/packages/tests/fixtures/video_short.webm.jpg differ
diff --git a/packages/tests/fixtures/video_short1-preview.webm.jpg b/packages/tests/fixtures/video_short1-preview.webm.jpg
index 60b6927748..de930f2d72 100644
Binary files a/packages/tests/fixtures/video_short1-preview.webm.jpg and b/packages/tests/fixtures/video_short1-preview.webm.jpg differ
diff --git a/packages/tests/fixtures/video_short1.webm.jpg b/packages/tests/fixtures/video_short1.webm.jpg
index 13922ca51a..88d950b3d6 100644
Binary files a/packages/tests/fixtures/video_short1.webm.jpg and b/packages/tests/fixtures/video_short1.webm.jpg differ
diff --git a/packages/tests/fixtures/video_short2.webm.jpg b/packages/tests/fixtures/video_short2.webm.jpg
index 1920f2348b..1016f63549 100644
Binary files a/packages/tests/fixtures/video_short2.webm.jpg and b/packages/tests/fixtures/video_short2.webm.jpg differ
diff --git a/packages/tests/fixtures/video_short3.webm.jpg b/packages/tests/fixtures/video_short3.webm.jpg
index 857b3d1c16..f5fabefbdf 100644
Binary files a/packages/tests/fixtures/video_short3.webm.jpg and b/packages/tests/fixtures/video_short3.webm.jpg differ
diff --git a/server/core/lib/thumbnail.ts b/server/core/lib/thumbnail.ts
index 14b849fb4e..41479638c1 100644
--- a/server/core/lib/thumbnail.ts
+++ b/server/core/lib/thumbnail.ts
@@ -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 })