Skip to content

Commit

Permalink
fix(server): handle N/A duration response from ffprobe (#13803)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Oct 29, 2024
1 parent 00dd941 commit e029190
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/src/repositories/media.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}
}

0 comments on commit e029190

Please sign in to comment.