Skip to content

Commit 08c1886

Browse files
committed
Improve audio timestamp calculation by validating frame size
1 parent 5d783cc commit 08c1886

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/api/demuxer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ export class Demuxer implements AsyncDisposable, Disposable {
19131913
switch (par.codecType) {
19141914
case AVMEDIA_TYPE_AUDIO:
19151915
// Audio: duration from sample_rate or packet duration
1916-
if (par.sampleRate > 0) {
1916+
if (par.sampleRate >= 1 && par.frameSize > 0) {
19171917
state.nextDts += (BigInt(AV_TIME_BASE) * BigInt(par.frameSize)) / BigInt(par.sampleRate);
19181918
} else {
19191919
state.nextDts += avRescaleQ(packet.duration, packet.timeBase, AV_TIME_BASE_Q);

0 commit comments

Comments
 (0)