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
yarn add ms-video-indexer
pnpm install ms-video-indexer
npm install --save ms-video-indexer
- 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
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,
})
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
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:
- the interface is shown below and only
name
is required since you providelocation
andaccountId
when instantiating the object - you can find detailed description for each field here: https://api-portal.videoindexer.ai/api-details#api=Operations&operation=Upload-Video
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
}
Used to retrieve/fetch the result of a successful index operation.
videoId
Type: string
The id of the indexed video.
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