Releases: diffusionstudio/ffmpeg-js
Releases · diffusionstudio/ffmpeg-js
v0.2.0
There are two new features:
Metadata
// Get the metadata of a given input (url or blob)
console.log(await ffmpeg.meta('/samples/video.mp4'));
This is what an example output looks like:
{
"duration": 30.53,
"bitrate": "411 kb/s",
"formats": ["mov", "mp4", "m4a"],
"streams": {
"audio": [
{
"id": "0:1",
"codec": "aac",
"sampleRate": 48000
}
],
"video": [
{
"id": "0:0",
"codec": "h264",
"width": 480,
"height": 270,
"fps": 30
}
]
}
}
Thumbnails
Generate a number of thumbnails, this feature is very helpful for creating a timeline visualization of a video as seen in the Demo App
// Required parameters
const source = '/samples/video.mp4'; // can be blob
// Optional parameters
const count = 9; // total number of images
const start = 2; // in seconds
const stop = 8; // in seconds
// type AsyncGenerator<Blob, void, void>
const generator = ffmpeg.thumbnails(source, count, start, stop);
// iterate async
for await (const image of generator) {
const img = document.createElement('img');
img.src = URL.createObjectURL(image);
document.body.appendChild(img);
}
This script will append 9 images to the document body
v0.1.0
v0.0.2
Breaking Changes
- Streamlined FFmpeg instantiation interface,
lib
has been renamed toconfig
and thelogger
property has been replaced with a boolean:
// old interface (v0.0.1)
const logger = () => null;
const ffmpeg = new FFmpeg({ logger, lib: 'gpl-extended' });
// new interface (v0.0.2)
const ffmpeg = new FFmpeg({ log: false, config: 'gpl-extended' });
// need to intercept messages? Do this:
ffmpeg.onMessage((msg) => console.log(msg));
- Added more tests