79249955 by Bernd Paradies

Fixes issue 101

1 parent 589e8dc4
...@@ -38,7 +38,8 @@ ...@@ -38,7 +38,8 @@
38 headBytes = new Uint8Array(3 + 1 + 1 + 4), 38 headBytes = new Uint8Array(3 + 1 + 1 + 4),
39 head = new DataView(headBytes.buffer), 39 head = new DataView(headBytes.buffer),
40 metadata, 40 metadata,
41 result; 41 result,
42 metadataLength;
42 43
43 // default arguments 44 // default arguments
44 duration = duration || 0; 45 duration = duration || 0;
...@@ -73,9 +74,10 @@ ...@@ -73,9 +74,10 @@
73 metadata = new FlvTag(FlvTag.METADATA_TAG); 74 metadata = new FlvTag(FlvTag.METADATA_TAG);
74 metadata.pts = metadata.dts = 0; 75 metadata.pts = metadata.dts = 0;
75 metadata.writeMetaDataDouble("duration", duration); 76 metadata.writeMetaDataDouble("duration", duration);
76 result = new Uint8Array(headBytes.byteLength + metadata.byteLength); 77 metadataLength = metadata.finalize().length;
77 result.set(head); 78 result = new Uint8Array(headBytes.byteLength + metadataLength);
78 result.set(head.bytesLength, metadata.finalize()); 79 result.set(headBytes);
80 result.set(head.byteLength, metadataLength);
79 81
80 return result; 82 return result;
81 }; 83 };
......