SOURCE

console 命令行工具 X clear

                    
>
console
let ready_frames = [];
let underflow = true;




(async function () {


    let url = 'https://editor-engine.test.bhbapp.cn/videos/b.mp4';

    async function renderFrame() {
        if (ready_frames.length == 0) {
            underflow = true;
            return;
        }
        let frame = ready_frames.shift();
        underflow = false;

        ctx.drawImage(frame, 0, 0);
        frame.close();

        // Immediately schedule rendering of the next frame
        setTimeout(renderFrame, 0);
    }

    function handleFrame(frame) {
        ready_frames.push(frame);
        console.log('i')
        if (underflow) {
            underflow = false;
            setTimeout(renderFrame, 0);
        }
    }

    const init = {
        output: handleFrame,
        error: reportError
    };

    const config = {
        codec: "h.264",
        codedWidth: 640,
        codedHeight: 480,
    };

    console.log('init')
    let decoder = new VideoDecoder(init);
    console.log('init2',decoder);
    decoder.configure(config);
    console.log('init3')

})(window);
<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>WebCodecs demo: Encoding and Decoding</title>
	<style>
		canvas {
			padding: 10px;

			margin: 5px;
		}
	</style>
</head>

<body>
	<canvas id="src" width="640" height="480"></canvas>
</body>

</html>