
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
ffmpeg-webworker
Advanced tools
A WebWorker implementation that eases the use of ffmpeg library in the browser.
A WebWorker implementation that eases the use of ffmpeg library in the browser.
This builds upon an existing work geniusly done by the folks at Ffmpeg.js and videoconverter.js
npm install --save ffmpeg-webworker
or:
yarn add ffmpeg-webworker
import workerClient from "ffmpeg-webworker";
import React from "react";
class FFMPEG extends React.Component {
constructor(props) {
super(props);
this.state = {
stdOutputText: "",
ffmpegReady: false
};
this.updateStdOutputText = this.updateStdOutputText.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
this.handleListCodecs = this.handleListCodecs.bind(this);
}
componentWillMount() {
workerClient.on("onReady", () => this.setState({ ffmpegReady: true }));
workerClient.on("onStdout", msg => this.updateStdOutputText(msg));
workerClient.on("onFileReceived", msg => this.updateStdOutputText(msg));
workerClient.on("onDone", data => {
this.updateStdOutputText("Command Completed, check the console");
console.log(data);
});
}
updateStdOutputText(text) {
this.setState({
stdOutputText: `${this.state.stdOutputText} \n\n ${text}`
});
}
handleInputChange(e) {
this.setState({ stdOutputText: "" });
const file = e.currentTarget.files[0];
// Set the file for processing
workerClient.inputFile = file;
// Run a valid ffmpeg command
workerClient.runCommand("-ss 00:00:05 -c copy -t 12 sliced-output.mp4");
}
Input({ onChange }) {
return (
<input type="file" accept="audio/*,video/*" onChange={e => onChange(e)} />
);
}
StdOutput({ text, ffmpegReady }) {
return (
<pre>
{ffmpegReady ? "FFMPEG is ready" : "Loading FFMPEG"}
{text}
</pre>
);
}
handleListCodecs(e) {
e.preventDefault();
this.setState({ stdOutputText: "" });
// Run a valid ffmpeg command
workerClient.runCommand("-codecs");
}
render() {
return (
<div>
{<this.Input onChange={this.handleInputChange} />}
<button onClick={this.handleListCodecs}>List Codecs</button>
<this.StdOutput
text={this.state.stdOutputText}
ffmpegReady={this.state.ffmpegReady}
/>
</div>
);
}
}
<FFMPEG />;
The default export from the library is a standard NodeJS event emitter client would listen to and dispatch events based on interactions with an already loaded ffmpeg webworker Javascript library inside of a webworker.
It supports the following properties:
Receives an event from the ffmpeg webworker. Below are the supported commands:
The file that ffmpeg-webworker would be working with on issue of command.
An instance of the web worker that has ffmpeg-js loaded in it.
Converts the passed file to a file buffer array.
Detects if the inputFile has been passed in correctly.
Converts already set input file in the library to Buffer Array for processing
Accepts a valid ffmpeg command to be run against the input file
Logs messages to standard console.
This is the default exported property of the module. It ease the interaction with the already initialized and loaded ffmpeg webworker Javascript library.
Other exported modules are:
The official web worker implementation that makes easier the loading of ffmpeg-js and running command in a worker.
Official listener for FFMPEGWebworker.
import { FFMPEGWebworkerClient } from "ffmpeg-webworker";
const webworkerClient = new FFMPEGWebworkerClient();
// The above is same as
// import webworkerClient from "ffmpeg-webworker";
webworkerClient.on("ready", () => {
console.log("FFMPEG has been loaded, and can receive commands");
});
1.0.0
Initial Release:
Github issues can be used to log bug reports, suggestions and improvements
You can fork, then send a pull request.
Thank you...
MIT
This library has been made possible with the awesome work by folks at Ffmpeg.js
FAQs
A WebWorker implementation that eases the use of ffmpeg library in the browser.
The npm package ffmpeg-webworker receives a total of 28 weekly downloads. As such, ffmpeg-webworker popularity was classified as not popular.
We found that ffmpeg-webworker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.