muaz-khan / concatenateblobs Goto Github PK
View Code? Open in Web Editor NEWSimply pass array of blobs. This javascript library will concatenate all blobs in single Blob object.
Home Page: https://www.webrtc-experiment.com/ConcatenateBlobs/
Simply pass array of blobs. This javascript library will concatenate all blobs in single Blob object.
Home Page: https://www.webrtc-experiment.com/ConcatenateBlobs/
Hello. This is package is exactly what I need.
Unfortunately it is not working.
Is it still active the project?
I am passing the array of blobs but I am getting the following error:
Failed to execute 'readAsArrayBuffer' on 'FileReader': parameter 1 is not of type 'Blob'.
I am simply calling the function and passing my array of blobs:
ConcatenateBlobs([this.blobArray], 'audio/wav', function(resultingBlob) {
console.log({resultingBlob})
});
Do you know why this is happening?
Thanks!
An updated version. Let me know what you think. There are a few notes/TODOs. I'm not entirely confident in it, but I'm sure that the delete call from before was not working as intended.
function concatenateBuffers() {
var byteLength = 0;
buffers.forEach(function(buffer) {
byteLength += buffer.byteLength;
// TODO(datermine): Figure out if this is necessary.
if (buffer.byteLength % 2 != 0) {
byteLength--;
}
});
var tmp = new Uint16Array(byteLength);
var lastOffset = 0;
buffers.forEach(function(buffer) {
// BYTES_PER_ELEMENT == 2 for Uint16Array
var bufferByteLength = buffer.byteLength;
if (bufferByteLength % 2 != 0) {
// NOTE(datermine): Uses to delete, now we use slice.
// delete buffer[bufferByteLength - 1];
buffer = buffer.slice(0, bufferByteLength - 1)
// NOTE(datermine): Once we slice instead of delete, this is really
// no longer necessary as it's the same as buffer.byteLength
bufferByteLength -= 1;
}
tmp.set(new Uint16Array(buffer), lastOffset);
// NOTE(datermine): We could just use buffer.byteLength here.
lastOffset += bufferByteLength;
});
var blob = new Blob([tmp.buffer], {
type: type
});
callback(blob);
}
I tried to concat my webm blobs but doesn't work...
ConcatenateBlobs(window.arrVideoBlob, document.getElementById('video').getAttribute('data-type'), function(resultingBlob) {
console.log(bytesToSize(resultingBlob.size));
document.getElementById('video').src = URL.createObjectURL(resultingBlob);
document.getElementById('video').play();
});
this is the code
Why would you need a lib for this?
isn't this enought?
a = new Blob(["a"])
b = new Blob(["b"])
ab = new Blob([a,b])
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.