Skip to content

Commit

Permalink
Fix crash when generated video had 0 frames, fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
thenickdude committed Sep 20, 2019
1 parent 329cb97 commit 7945d3c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/WebMWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
DEFAULT_TRACK_NUMBER = 1,

writtenHeader = false,
videoWidth, videoHeight,
videoWidth = 0, videoHeight = 0,

clusterFrameBuffer = [],
clusterStartTime = 0,
Expand Down Expand Up @@ -403,7 +403,9 @@
// Now we know where these top-level elements lie in the file:
seekPoints.SegmentInfo.positionEBML.data = fileOffsetToSegmentRelative(segmentInfo.offset);
seekPoints.Tracks.positionEBML.data = fileOffsetToSegmentRelative(tracks.offset);
};

writtenHeader = true;
}

/**
* Create a SimpleBlock keyframe header using these fields:
Expand Down Expand Up @@ -615,7 +617,6 @@
videoHeight = canvas.height || 0;

writeHeader();
writtenHeader = true;
}

var
Expand All @@ -638,6 +639,10 @@
* a Blob with the contents of the entire video.
*/
this.complete = function() {
if (!writtenHeader) {
writeHeader();
}

flushClusterFrameBuffer();

writeCues();
Expand Down

0 comments on commit 7945d3c

Please sign in to comment.