Reputation: 1062
I'd like to grab the video stream of a selected mp4 to decode it later:
async onFileSelected(event: Event) {
const file: File = (event as any).target.files[0];
console.log(file);
const sourceBuffer = await file.arrayBuffer();
const worker = new Worker('ffmpeg-worker-mp4.js');
let output;
worker.onmessage = function (e) {
const msg = e.data;
switch (msg.type) {
case 'ready':
worker.postMessage({
type: 'run',
MEMFS: [
{ name: 'test.mp4', data: sourceBuffer },
{ name: 'test.h264', data: output },
],
arguments: [
'-i',
'test.mp4',
'-c:v',
'copy',
'-bsf:v',
'h264_mp4toannexb',
'-an',
'-f',
'h264',
'test.h264',
],
});
break;
case 'stdout':
console.log(msg.data);
break;
case 'stderr':
console.log(msg.data);
break;
case 'done':
console.log(msg.data);
console.log(output);
break;
}
};
}
I receive the following errors:
Requested output format 'h264' is not a suitable output format test.h264: Invalid argument
I tested the same command using my command line and it works fine. What am I missing?
Upvotes: 0
Views: 191