123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- // vDecoder example
- import { VDecoder } from "./VDecoder.js";
- // 测试用
- import { initWebGLCanvas, draw } from "../video/test.js";
- // decoder
- // const socket = io("ws://192.168.0.150:3000", {
- // reconnectionDelayMax: 10000,
- // });
- // socket.on("connect", (data) => {
- // console.log("socket connect");
- // });
- const vDecoder = new VDecoder({
- maxChip: 100,
- });
- vDecoder.on("ready", () => {
- console.log("ready");
- // 测试canvas
- initWebGLCanvas();
- vDecoder.mutiFetch([
- {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- },
- {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- }, {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- }, {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- }, {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- }, {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- }, {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- }, {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- frame: 1,
- },
- {
- path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/2",
- frame: 2,
- },
- ]);
- vDecoder.on("fetchDone", (clip) => {
- console.log("fetchDone", clip);
- });
- //监听 decodeData
- vDecoder.on("decodeData", (data) => {
- // console.log("decodeData", data);
- const { width, height, data: buffer } = data;
- draw(new Uint8Array(buffer), width, height);
- // window.updateTexture( new Uint8Array(buffer) );
- // window.up
- });
- vDecoder.on("decodeDone", async (id) => {
- let clipId = null;
- // vDecoder.flush();
- // vDecoder.fetch({
- // path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
- // range: [0, 66],
- // });
- // console.log("clipId", clipId);
- });
- });
|