Drag 0-duration VideoFrame duration to null (fixes #116)

This commit is contained in:
Vanilagy
2025-09-16 15:50:14 +02:00
parent fcec67645a
commit 530ccd7523
2 changed files with 8 additions and 6 deletions
+4 -3
View File
@@ -201,7 +201,8 @@ export class VideoSample {
return new VideoSample(
new VideoFrame(data, {
timestamp: Math.trunc(init.timestamp! * SECOND_TO_MICROSECOND_FACTOR),
duration: Math.trunc((init.duration ?? 0) * SECOND_TO_MICROSECOND_FACTOR),
// Drag 0 to undefined
duration: Math.trunc((init.duration ?? 0) * SECOND_TO_MICROSECOND_FACTOR) || undefined,
}),
init,
);
@@ -373,13 +374,13 @@ export class VideoSample {
codedWidth: this.codedWidth,
codedHeight: this.codedHeight,
timestamp: this.microsecondTimestamp,
duration: this.microsecondDuration,
duration: this.microsecondDuration || undefined,
colorSpace: this.colorSpace,
});
} else {
return new VideoFrame(this._data, {
timestamp: this.microsecondTimestamp,
duration: this.microsecondDuration,
duration: this.microsecondDuration || undefined,
});
}
}