1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-01 08:31:59 +00:00

feat(server): better video thumbnails (#9784)

This commit is contained in:
Mert 2024-05-27 12:08:38 -04:00 committed by GitHub
parent 298370b7be
commit 351dd647a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 10 deletions

View file

@ -294,11 +294,13 @@ describe(MediaService.name, () => {
'/original/path.ext', '/original/path.ext',
'upload/thumbs/user-id/as/se/asset-id-preview.jpeg', 'upload/thumbs/user-id/as/se/asset-id-preview.jpeg',
{ {
inputOptions: ['-ss 00:00:00', '-sws_flags accurate_rnd+bitexact+full_chroma_int'], inputOptions: ['-skip_frame nokey', '-sws_flags accurate_rnd+full_chroma_int'],
outputOptions: [ outputOptions: [
'-fps_mode vfr',
'-frames:v 1', '-frames:v 1',
'-update 1',
'-v verbose', '-v verbose',
'-vf scale=-2:1440:flags=lanczos+accurate_rnd+bitexact+full_chroma_int:out_color_matrix=601:out_range=pc,format=yuv420p', `-vf fps=12,thumbnail=12,select=gt(scene\\,0.1)+gt(n\\,20),scale=-2:1440:flags=lanczos+accurate_rnd+full_chroma_int:out_color_matrix=601:out_range=pc,format=yuv420p`,
], ],
twoPass: false, twoPass: false,
}, },
@ -319,11 +321,13 @@ describe(MediaService.name, () => {
'/original/path.ext', '/original/path.ext',
'upload/thumbs/user-id/as/se/asset-id-preview.jpeg', 'upload/thumbs/user-id/as/se/asset-id-preview.jpeg',
{ {
inputOptions: ['-ss 00:00:00', '-sws_flags accurate_rnd+bitexact+full_chroma_int'], inputOptions: ['-skip_frame nokey', '-sws_flags accurate_rnd+full_chroma_int'],
outputOptions: [ outputOptions: [
'-fps_mode vfr',
'-frames:v 1', '-frames:v 1',
'-update 1',
'-v verbose', '-v verbose',
'-vf zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=601:m=bt470bg:range=pc,format=yuv420p', `-vf fps=12,thumbnail=12,select=gt(scene\\,0.1)+gt(n\\,20),zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=601:m=bt470bg:range=pc,format=yuv420p`,
], ],
twoPass: false, twoPass: false,
}, },
@ -346,11 +350,13 @@ describe(MediaService.name, () => {
'/original/path.ext', '/original/path.ext',
'upload/thumbs/user-id/as/se/asset-id-preview.jpeg', 'upload/thumbs/user-id/as/se/asset-id-preview.jpeg',
{ {
inputOptions: ['-ss 00:00:00', '-sws_flags accurate_rnd+bitexact+full_chroma_int'], inputOptions: ['-skip_frame nokey', '-sws_flags accurate_rnd+full_chroma_int'],
outputOptions: [ outputOptions: [
'-fps_mode vfr',
'-frames:v 1', '-frames:v 1',
'-update 1',
'-v verbose', '-v verbose',
'-vf zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=601:m=bt470bg:range=pc,format=yuv420p', `-vf fps=12,thumbnail=12,select=gt(scene\\,0.1)+gt(n\\,20),zscale=t=linear:npl=100,tonemap=hable:desat=0,zscale=p=bt709:t=601:m=bt470bg:range=pc,format=yuv420p`,
], ],
twoPass: false, twoPass: false,
}, },

View file

@ -319,10 +319,15 @@ export class BaseHWConfig extends BaseConfig implements VideoCodecHWConfig {
export class ThumbnailConfig extends BaseConfig { export class ThumbnailConfig extends BaseConfig {
getBaseInputOptions(): string[] { getBaseInputOptions(): string[] {
return ['-ss 00:00:00', '-sws_flags accurate_rnd+bitexact+full_chroma_int']; return ['-skip_frame nokey', '-sws_flags accurate_rnd+full_chroma_int'];
} }
getBaseOutputOptions() { getBaseOutputOptions() {
return ['-frames:v 1']; return ['-fps_mode vfr', '-frames:v 1', '-update 1'];
}
getFilterOptions(videoStream: VideoStreamInfo): string[] {
return ['fps=12', 'thumbnail=12', `select=gt(scene\\,0.1)+gt(n\\,20)`, ...super.getFilterOptions(videoStream)];
} }
getPresetOptions() { getPresetOptions() {
@ -338,8 +343,7 @@ export class ThumbnailConfig extends BaseConfig {
} }
getScaling(videoStream: VideoStreamInfo) { getScaling(videoStream: VideoStreamInfo) {
let options = super.getScaling(videoStream); let options = super.getScaling(videoStream) + ':flags=lanczos+accurate_rnd+full_chroma_int';
options += ':flags=lanczos+accurate_rnd+bitexact+full_chroma_int';
if (!this.shouldToneMap(videoStream)) { if (!this.shouldToneMap(videoStream)) {
options += ':out_color_matrix=601:out_range=pc'; options += ':out_color_matrix=601:out_range=pc';
} }