Skip to content

Commit adf65f4

Browse files
josephroccadalecurtis
authored andcommitted
Add nixxquality's fixes
See: #332 (comment)
1 parent e8fc435 commit adf65f4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

samples/capture-to-file/webm-writer2.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Note that these two fixes have been applied:
2+
// https://github.com/w3c/webcodecs/issues/332#issuecomment-1077442192
3+
// Ctrl+F for "firstCueWritten" and "MAX_CLUSTER_DURATION_MSEC" to see the changes.
4+
15
/**
26
* A tool for presenting an ArrayBuffer as a stream for writing some simple data
37
* types.
@@ -630,7 +634,7 @@ function writeEBML(buffer, bufferFileOffset, ebml) {
630634
*/
631635
let WebMWriter = function(ArrayBufferDataStream, BlobBuffer) {
632636
return function(options) {
633-
let MAX_CLUSTER_DURATION_MSEC = 5000000, DEFAULT_TRACK_NUMBER = 1,
637+
let MAX_CLUSTER_DURATION_MSEC = 5000, DEFAULT_TRACK_NUMBER = 1,
634638
writtenHeader = false, videoWidth = 0, videoHeight = 0,
635639
firstTimestampEver = true, earliestTimestamp = 0,
636640

@@ -972,7 +976,11 @@ let WebMWriter = function(ArrayBufferDataStream, BlobBuffer) {
972976
* CuePoints (use addCuePoint()). The seek entry for the Cues in the
973977
* SeekHead is updated.
974978
*/
979+
let firstCueWritten = false;
975980
function writeCues() {
981+
if(firstCueWritten) return;
982+
firstCueWritten = true;
983+
976984
let ebml = {'id': 0x1C53BB6B, 'data': cues},
977985

978986
cuesBuffer = new ArrayBufferDataStream(

0 commit comments

Comments
 (0)