This commit is contained in:
Maciej Caderek
2022-01-22 06:00:40 +01:00
parent 6112c00dec
commit ec7a11c9b6
20 changed files with 262 additions and 139 deletions

37
src/encoders/MP4.ts Normal file
View File

@@ -0,0 +1,37 @@
import * as HME from "h264-mp4-encoder";
class MP4 {
private hme: Promise<HME.H264MP4Encoder>;
private encoder: HME.H264MP4Encoder | null = null;
constructor(width: number, height: number) {
this.hme = HME.createH264MP4Encoder();
this.setup(width, height);
}
async setup(width: number, height: number) {
this.encoder = await this.hme;
this.encoder.width = width;
this.encoder.height = height;
this.encoder.initialize();
}
// add(frame: CanvasImageSource | string, delay: number) {
// // this.encoder?.addFrameRgba()
// }
// async render(): Promise<File> {
// const blob = await this.video.complete();
// const timestamp = Date.now();
// const file = new File([blob], `board_${timestamp}.webm`, {
// type: "video/webm",
// lastModified: timestamp,
// });
// return file;
// }
}
export default MP4;