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

fix(server): handle N/A duration response from ffprobe (#13803)

This commit is contained in:
Jason Rasmussen 2024-10-29 10:21:30 -04:00 committed by GitHub
parent 00dd9419a5
commit e029190a5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,16 +110,16 @@ export class MediaRepository implements IMediaRepository {
format: { format: {
formatName: results.format.format_name, formatName: results.format.format_name,
formatLongName: results.format.format_long_name, formatLongName: results.format.format_long_name,
duration: results.format.duration || 0, duration: this.parseFloat(results.format.duration),
bitrate: results.format.bit_rate ?? 0, 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')
.filter((stream) => !stream.disposition?.attached_pic) .filter((stream) => !stream.disposition?.attached_pic)
.map((stream) => ({ .map((stream) => ({
index: stream.index, index: stream.index,
height: stream.height || 0, height: this.parseInt(stream.height),
width: stream.width || 0, width: 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),
@ -215,4 +215,8 @@ export class MediaRepository implements IMediaRepository {
private parseInt(value: string | number | undefined): number { private parseInt(value: string | number | undefined): number {
return Number.parseInt(value as string) || 0; return Number.parseInt(value as string) || 0;
} }
private parseFloat(value: string | number | undefined): number {
return Number.parseFloat(value as string) || 0;
}
} }