0.2.4 • Published 2 years ago

ms-video-indexer v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

MS Azure Video Indexer

Unofficial Javascript client library for Azure Video Indexer, with support for a couple of API's: accessToken, index/upload video, indexed Output, and image (Jpeg/base64) from thumbnail-id. Feel free to contribute an API you find useful to your project

Installation

yarn add ms-video-indexer

pnpm install ms-video-indexer

npm install --save ms-video-indexer

TODO

  • Add major handlers for relevant APIs
    • fetch and cache access token
    • index video file from a downloadable URI
    • get result of video analysis
    • get video thumbnails for any item/model which described the video, such as face, scene or shot.
  • Jest Test.
  • Examples
  • Handlers for other API calls to be implemented based on need/request

Example/Usage

import videoIndexer from 'ms-video-indexer'

const api = videoIndexer({
  accountId: 'the-account-id',
  location: 'the-location',
  subscriptionKey: 'the-subscription-key',
})

// to get the cached token
const accessToken = await api.getToken()

// to index a video
const videoURL = 'https://url-to-a-downloadable-cloud-resource'
const uuid = 'id-recognising-the-video-on-your-platform'

await api.indexVideo(videoURL, {
  name: 'Into the Spiderverse',
  externalId: uuid,
})

API

getToken(forceFetch?)

Returns a promise to a cached access token. This functions ensures you don't always have to poll the access token

  • it's fetched once and cached using simple cache for t < 60sec before it's refreshed.
  • token is always valid within a 1hr expiry period.

forceFetch Type: undefined|boolean

Set to true to fetch a new token

indexVideo(videoURL, options)

Used to ingest a video to be analyzed.

videoURL Type: string

Video file url to analyze. The URL must point to a media file (HTML pages are not supported). Please read more here. Be aware of cases where the video file is protected by an access token and note that those must be encoded properly. See this Stack Overflow question

options Type: UploadVideoRequest

Custom options for your video like name and externalId. Please note the following about the interface:

interface UploadVideoRequest {
  location?: string
  accountId?: string
  name: string
  privacy?: 'Private' | 'Public'
  priority?: 'Low' | 'Normal' | 'High'
  description?: string
  partition?: string
  externalId?: string
  externalUrl?: string
  callbackUrl?: string
  metadata?: string
  language?: string
  videoUrl?: string
  fileName?: string
  indexingPreset?:
    | 'Default'
    | 'AudioOnly'
    | 'VideoOnly'
    | 'BasicAudio'
    | 'Advanced'
    | 'AdvancedAudio'
    | 'AdvancedVideo'
  streamingPreset?:
    | 'NoStreaming'
    | 'Default'
    | 'SingleBitrate'
    | 'AdaptiveBitrate'
  linguisticModelId?: string
  personModelId?: string
  animationModelId?: string
  sendSuccessEmail?: boolean
  assetId?: string
  brandsCategories?: string
}

getIndexedOutput(videoId)

Used to retrieve/fetch the result of a successful index operation.

videoId Type: string

The id of the indexed video.

getThumbnail(videoId, thumbnailId, format?)

Used to retrieve video thumbnail.

videoId Type: string

Id of the indexed video.

thumbnailId Type: string

A guid string identifying the thumbnail.

format Type: undefined|'base64'|'Jpeg'

The preferred thumbnail format. Allowed values are Jpeg and Base64. Defaults to base64

References

0.2.3

2 years ago

0.2.4

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.16

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.0.15

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago