npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ms-video-indexer

v0.2.4

Published

Unofficial Javascript client library for Microsoft Video Analyzer

Downloads

39

Readme

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

  • [x] 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.
  • [x] Jest Test.
  • [x] 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:

  • the interface is shown below and only name is required since you provide location and accountId 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
}

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