2024-09-19 12:16:39 -03:00
2024-09-13 14:09:38 -03:00
2024-09-13 13:52:28 -03:00
2024-09-18 16:06:51 -03:00
2024-09-13 13:52:28 -03:00
2024-09-13 14:09:38 -03:00
2024-09-13 13:52:28 -03:00
2024-09-13 13:52:28 -03:00
2024-09-13 13:52:28 -03:00
2024-09-16 07:21:33 -03:00
2024-09-18 16:09:25 -03:00
2024-09-16 07:21:33 -03:00

What Is This?

This is a collection of utilities for working with Google Video APIs, with a primary focus on UMP.

You can find usage examples here.

Installation

npm install github:LuanRT/googlevideo

Basic Usage

import GoogleVideo, { PART, Protos } from 'googlevideo';

const streamingUrl = 'https://abcd--a.googlevideo.com/videoplayback?...';

const response = await fetch(streamingUrl, { method: 'POST' });

const arrayBuffer = await response.arrayBuffer();

const dataBuffer = new GoogleVideo.ChunkedDataBuffer();
dataBuffer.append(new Uint8Array(arrayBuffer));

const googUmp = new GoogleVideo.UMP(dataBuffer);

googUmp.parse((part) => {
  switch (part.type) {
    case PART.MEDIA_HEADER: {
      console.log('[MediaHeader]:', Protos.MediaHeader.decode(part.data.chunks[0]));
      break;
    }
    case PART.MEDIA: {
      const headerId = part.data.getUint8(0);
      const streamData = part.data.split(1).remainingBuffer;
      console.log('[Media]:', `Header ID: ${headerId}`, `length: ${streamData.byteLength}`);
      break;
    }
    case PART.MEDIA_END: {
      const headerId = part.data.getUint8(0);
      console.log('[MediaEnd]:', `Header ID: ${headerId}`);
      break;
    }
    default:
      console.log('Unhandled part:', part.type);
      break;
  }
});

For more advanced examples, including scenarios beyond just parsing responses, check out the examples.

License

Distributed under the MIT License.

(back to top)

Description
No description provided
Readme MIT 1.4 MiB
Languages
TypeScript 96.6%
JavaScript 3.4%