From e029190a5d8fe0f6b2ddd15d5f7ce8d8e4bc4ad5 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Tue, 29 Oct 2024 10:21:30 -0400 Subject: [PATCH] fix(server): handle N/A duration response from ffprobe (#13803) --- server/src/repositories/media.repository.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/repositories/media.repository.ts b/server/src/repositories/media.repository.ts index 7e1ca84993..d76d226f44 100644 --- a/server/src/repositories/media.repository.ts +++ b/server/src/repositories/media.repository.ts @@ -110,16 +110,16 @@ export class MediaRepository implements IMediaRepository { format: { formatName: results.format.format_name, formatLongName: results.format.format_long_name, - duration: results.format.duration || 0, - bitrate: results.format.bit_rate ?? 0, + duration: this.parseFloat(results.format.duration), + bitrate: this.parseInt(results.format.bit_rate), }, videoStreams: results.streams .filter((stream) => stream.codec_type === 'video') .filter((stream) => !stream.disposition?.attached_pic) .map((stream) => ({ index: stream.index, - height: stream.height || 0, - width: stream.width || 0, + height: this.parseInt(stream.height), + width: this.parseInt(stream.width), codecName: stream.codec_name === 'h265' ? 'hevc' : stream.codec_name, codecType: stream.codec_type, 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 { return Number.parseInt(value as string) || 0; } + + private parseFloat(value: string | number | undefined): number { + return Number.parseFloat(value as string) || 0; + } }