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