can not render alpha video with canvas
Closed this issue · 1 comments
muxer = new WebMMuxer.Muxer({
target: new WebMMuxer.ArrayBufferTarget(),
video: {
codec: 'V_VP9',
width: canvas.width,
height: canvas.height,
alpha: true
},
audio: undefined,
fastStart: 'in-memory',
firstTimestampBehavior: 'offset'
});
videoEncoder = new VideoEncoder({
output: (chunk, meta) => muxer.addVideoChunk(chunk, meta),
error: e => console.error(e)
});
videoEncoder.configure({
codec: 'vp09.00.10.08',
width: canvas.width,
height: canvas.height,
bitrate: 1e6,
});
encodeVideoFrame();
intervalId = setInterval(encodeVideoFrame, 1000 / 30);
const encodeVideoFrame = () => {
const canvas = document.querySelector('canvas');
let elapsedTime = document.timeline.currentTime - startTime;
let frame = new VideoFrame(canvas, {
timestamp: framesGenerated * 1e6 / 30 // Ensure equally-spaced frames every 1/30th of a second
});
framesGenerated++;
// Ensure a video key frame at least every 10 seconds for good scrubbing
let needsKeyFrame = elapsedTime - lastKeyFrame >= 10000;
if (needsKeyFrame) lastKeyFrame = elapsedTime;
videoEncoder.encode(frame, { keyFrame: needsKeyFrame });
frame.close();
};
Yes, not supported by VideoEncoder, unfortunately.