Skip to content

Commit

Permalink
fix: duration is NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
mekwall committed Apr 11, 2023
1 parent b61c914 commit a925a97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/FFmpeggy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ export class FFmpeggy extends (EventEmitter as new () => TypedEmitter<FFmpegEven
const info = parseInfo(txt);
if (info) {
debug("info: %o", info);
duration = info.duration;
if (info.duration) {
duration = info.duration;
}
}
}
const progress = parseProgress(txt);
Expand Down
4 changes: 2 additions & 2 deletions src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function parseProgress(data: string): FFmpeggyProgress | undefined {
}

interface FFmpegInfo {
duration: number;
duration?: number;
start: number;
bitrate: number;
}
Expand All @@ -57,7 +57,7 @@ export function parseInfo(data: string): FFmpegInfo | undefined {
return;
}
return {
duration: timerToSecs(matches[1]),
duration: matches[1] ? timerToSecs(matches[1]) : undefined,
start: Number(matches[2]),
bitrate: parseBitrate(Number(matches[3]), matches[4]),
};
Expand Down

0 comments on commit a925a97

Please sign in to comment.