Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide multi-purpose Worker.run(args, options) #3

Closed
caugner opened this issue Oct 31, 2019 · 2 comments
Closed

Provide multi-purpose Worker.run(args, options) #3

caugner opened this issue Oct 31, 2019 · 2 comments

Comments

@caugner
Copy link
Contributor

caugner commented Oct 31, 2019

Is your feature request related to a problem? Please describe.
So far, I have been using videoconverter.js, which provided a general-purpose ffmpeg_run() method that took arguments and files and returned a list of files as a result.

Describe the solution you'd like
It would be great if ffmpeg.js could offer an equivalent method. This would allow easy migration from videoconverter.js.

Describe alternatives you've considered
Alternatively, there could be a guide on how to migrate from videoconverter.js.

Additional context
One use case is giving ffmpeg an audio file and exporting several extracts into individual files:

// ffmpeg -i input.wav -map 0 -c copy -f segment -segment_time 120 -reset_timestamps 1 out%02d.wav

const blob = new Blob(/** from user */, { type: "audio/wav" });
const file = new File([blob], 'input.wav');

const fs = require('fs');
const { createWorker } = require('@ffmpeg/ffmpeg');

const worker = createWorker();

(async () => {
  await worker.load();
  const { files } = await worker.run('-i input.wav -map 0 -c copy -f segment -segment_time 120 -reset_timestamps 1 out%02d.wav', { files: [file] });
  files.forEach(file => fs.writeFileSync(file.name, file.data));
})();
@jeromewu
Copy link
Collaborator

jeromewu commented Nov 4, 2019

Good suggestion! I will add this API in next release.

@jeromewu
Copy link
Collaborator

jeromewu commented Nov 7, 2019

Hi, I have added Worker.run in ffmpeg.js v0.3.0, you can check here for usage: https://github.com/ffmpegjs/ffmpeg.js/blob/master/docs/api.md#worker-run

@jeromewu jeromewu closed this as completed Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants