Skip to content

Releases: diffusionstudio/ffmpeg-js

v0.2.0

08 Jul 16:54
Compare
Choose a tag to compare

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

04 Jul 16:05
Compare
Choose a tag to compare

Added progress callback function, that can be used like this:

ffmpeg.onProgress((frames: number) => {
        // Number of frames that have been rendered in total
        console.log('Frame=', frames);
});

v0.0.2

01 Jul 12:23
Compare
Choose a tag to compare

Breaking Changes

  • Streamlined FFmpeg instantiation interface, lib has been renamed to config and the logger 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