mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix: consider DAR when extracting video dimension (#25293)
* feat: consider DAR when extracting video dimension * move to probe * comment --------- Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
@@ -243,12 +243,14 @@ export class MediaRepository {
|
|||||||
bitrate: this.parseInt(results.format.bit_rate),
|
bitrate: this.parseInt(results.format.bit_rate),
|
||||||
},
|
},
|
||||||
videoStreams: results.streams
|
videoStreams: results.streams
|
||||||
.filter((stream) => stream.codec_type === 'video')
|
.filter((stream) => stream.codec_type === 'video' && !stream.disposition?.attached_pic)
|
||||||
.filter((stream) => !stream.disposition?.attached_pic)
|
.map((stream) => {
|
||||||
.map((stream) => ({
|
const height = this.parseInt(stream.height);
|
||||||
|
const dar = this.getDar(stream.display_aspect_ratio);
|
||||||
|
return {
|
||||||
index: stream.index,
|
index: stream.index,
|
||||||
height: this.parseInt(stream.height),
|
height,
|
||||||
width: this.parseInt(stream.width),
|
width: dar ? Math.round(height * dar) : this.parseInt(stream.width),
|
||||||
codecName: stream.codec_name === 'h265' ? 'hevc' : stream.codec_name,
|
codecName: stream.codec_name === 'h265' ? 'hevc' : stream.codec_name,
|
||||||
codecType: stream.codec_type,
|
codecType: stream.codec_type,
|
||||||
frameCount: this.parseInt(options?.countFrames ? stream.nb_read_packets : stream.nb_frames),
|
frameCount: this.parseInt(options?.countFrames ? stream.nb_read_packets : stream.nb_frames),
|
||||||
@@ -259,7 +261,8 @@ export class MediaRepository {
|
|||||||
colorPrimaries: stream.color_primaries,
|
colorPrimaries: stream.color_primaries,
|
||||||
colorSpace: stream.color_space,
|
colorSpace: stream.color_space,
|
||||||
colorTransfer: stream.color_transfer,
|
colorTransfer: stream.color_transfer,
|
||||||
})),
|
};
|
||||||
|
}),
|
||||||
audioStreams: results.streams
|
audioStreams: results.streams
|
||||||
.filter((stream) => stream.codec_type === 'audio')
|
.filter((stream) => stream.codec_type === 'audio')
|
||||||
.map((stream) => ({
|
.map((stream) => ({
|
||||||
@@ -352,4 +355,15 @@ export class MediaRepository {
|
|||||||
private parseFloat(value: string | number | undefined): number {
|
private parseFloat(value: string | number | undefined): number {
|
||||||
return Number.parseFloat(value as string) || 0;
|
return Number.parseFloat(value as string) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getDar(dar: string | undefined): number {
|
||||||
|
if (dar) {
|
||||||
|
const [darW, darH] = dar.split(':').map(Number);
|
||||||
|
if (darW && darH) {
|
||||||
|
return darW / darH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user