josephrocca / createWebMFromFrames.js

Creates a WebM video from a series of frames using the new WebCodecs API.

Home Page:https://josephrocca.github.io/createWebMFromFrames.js/demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

createWebMFromFrames.js

Creates a WebM video from a series of frames using the new WebCodecs API.

import createWebMFromFrames from "https://deno.land/x/create_webm_from_frames@v0.0.4/mod.js";

let fileHandle = await window.showSaveFilePicker({
  startIn: 'videos',
  suggestedName: 'myVideo.webm',
  types: [{
    description: 'Video File',
    accept: {'video/webm' :['.webm']},
  }],
});

let fileWritableStream = await fileHandle.createWritable();

let webm = createWebMFromFrames(fileWritableStream, {width:config.codedWidth, height:config.codedHeight, bitrate:10e6});

// The frames should be a `VideoFrame` which can be created from an image/canvas/etc. --> https://developer.mozilla.org/en-US/docs/Web/API/VideoFrame/VideoFrame
webm.addFrame(frame1);
webm.addFrame(frame2);

await webm.save();

About

Creates a WebM video from a series of frames using the new WebCodecs API.

https://josephrocca.github.io/createWebMFromFrames.js/demo

License:Apache License 2.0


Languages

Language:JavaScript 100.0%