Closed DanielcBatista closed 4 months ago
Hey worked! thanks for the help!
There is still a way without using FFmpeg in NodeJS, it allows you to download a file via a stream, but be careful, it still loads it into RAM! The developer gives you the opportunity to upload the file yourself to mp4box. Below I gave the code, which is not exactly TypeScript friendly, due to the old age of the libraries, but easily allows you to download a file from a stream without using ffmpeg.
function toArrayBuffer(buffer: Buffer) {
const arrayBuffer = new ArrayBuffer(buffer.length);
const view = new Uint8Array(arrayBuffer);
for (let i = 0; i < buffer.length; ++i) {
view[i] = buffer[i];
}
return arrayBuffer;
}
let fileStart = 0;
const extractResult = await GPMFExtract((isoFile) => {
const fileReadStream = createReadStream(resolve(your_file_path));
fileReadStream.on('data', (chunk: Buffer) => {
const arrayBuffer = toArrayBuffer(chunk);
if (arrayBuffer.byteLength === 0) throw new Error('File not compatible');
(arrayBuffer as any).fileStart = fileStart;
isoFile.appendBuffer(arrayBuffer as any);
fileStart += chunk.length;
});
fileReadStream.on('end', () => isoFile.flush());
}, {
browserMode: false,
useWorker: false,
});
Hello, i´m trying to get all files from my GOPRO hero 11. and i´m trying to parse all files to node.js to extract all data to JSON files. I´m getting this error.
and this is my code