limistah / ffmpeg-webworker

A WebWorker implementation that eases the use of ffmpeg library in the browser.
30 stars 9 forks source link

using many input files as an input to merge or concat or overlay #2

Closed numerized closed 4 years ago

numerized commented 4 years ago

HEllo! thanks for amazing lib! Is it possible to input as many files as we need to merge or overlay them through ffmpeg command like this:

ffmpeg -i input0.mp3 -i input1.mp3 -filter_complex amerge=inputs=2 -ac 2 output.mp3

Thanks for your help

limistah commented 4 years ago

Hi @numerized,

I have not tried this before, so I looked up the documentation for ffmpeg.js and they stated:

You need to pass Array of Object to MEMFS option with the following keys:

name (String) - File name, can't contain slashes. data (ArrayBuffer/ArrayBufferView/Array) - File data.

And in https://github.com/limistah/ffmpeg-webworker/blob/269c635d7b5d24f65aea0abf101a0150ba33bbad/src/FFMPEGWebWorker.js#L16, that is exactly what the webworker is doing.

So, you could create a new client for the worker class and modify the line at https://github.com/limistah/ffmpeg-webworker/blob/269c635d7b5d24f65aea0abf101a0150ba33bbad/src/FFMPEGWebWorkerClient.js#L52-L57 to accept an array instead of a single File object.