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

azure-media

v1.0.11

Published

Node SDK for Azure's Media Service

Downloads

3

Readme

Azure Media for Node.js

Attention!!! Many bugs. Still working on it..

Azure's Media REST API provides a way to store, encode, and deliver media (video and images). This library makes using the API easier.

var AzureMedia = require('azure-media');
var myconfig = require('./myconfig');

var api = new AzureMedia(myconfig); // {client_id: 'your azure media id', client_secret: 'your azure media secret'} 
api.init(function (err) {
    // do your work here or after this callback
});

Install

npm install azure-media

Using Microsoft's Documentation

All of the data structures and endpoints used in this library are documented in Azure Media Service REST API Reference.

Each subsection is modeled based on its "Entity Properties" section (eg. Asset Entity Properties).

Each model usable at API.rest.[lowercase model name] with create, get, update, list methods.

REST Endpoints

All REST endpoints are in the initialized api lib at api.rest.someendpoint (eg. api.rest.asset)

"data" is a JavaScript object for the appropriate endpoint model documented in the Properties section of each model in Azure Media Service REST API Reference.
Callbacks generally return an object, called a model. It uses VeryModel. VeryModel instances behave like normal objects. If you want a simpler object, call .toObject() and use the returned value.

Each endpoint will have some of the following methods:

update

Signature: update(id, data, callback)
Callback: function (err, model)

create

Signature: create(data, callback)
Callback: function(err, model)

Example:

api.rest.asset.create({Name: 'Some Asset'}, function (err, asset) {
    if (err) {
        console.log(err);
    } else {
        console.log("Created asset: " + asset.Id);
    }
});

delete

Signature: delete(id, callback)
Callback: function(err)

get

Signature: get(id, callback)
Callback: function(err, model)

list

Signature: list(callback, query)
Callback: function(err, model)

The query parameter is a JavaScript object of the query parameters documented in OData Query String Options (eg: {'$filter': "Name eq 'Bill'"})

###accesspolicy

AccessPolicys should be reused, rather than just creating a new one for every use. So rather than create, or trying to manage this yourself, use

Signature: findOrCreate(durationInMinutes, permissions, callback)
Callback: function (err, accesspolicy_model)

###assetfileindex ###ingestmanifestasset ###job

Signature: cancel(id, callback)
Callback: function (err)

###locator ###notificationendpoint ###tasktemplate ###asset

###contentkey ###ingestmanifest ###ingestmanifestfile ###jobtemplate ###mediaprocessor ###task

Models

Most callbacks return a VeryModel instance. These are based on Microsoft's documentation and are implemented in /models/

Some models have extra ORM-like methods, allowing you to interact with the model itself which will work with the Azure REST API behind the scenes.

###accesspolicy ###assetfileindex ###ingestmanifestasset ###job ###locator ###notificationendpoint ###tasktemplate ###asset ###contentkey ###ingestmanifest ###ingestmanifestfile ###jobtemplate ###mediaprocessor ###task

Workflow Methods

###uploadStream

api.uploadStream('somefile.mp4', fs.createReadStream('/some/file.mp4'), fs.statSync('/some/file.mp4').size, function (err, assetId) {
    if(!err) {
        console.log("done uploading");
    }
});

downloadStream

api.downloadStream(assetId, fs.createWriteStream('/some/download/path.mp4'), function (err) {
});

getDownloadURL

api.getDownloadURL(assetId, fs.createWriteStream('/some/download/path.mp4'), function (err, url) {
});

encodeVideo

api.encodeVideo(assetId, 'H264 Broadband SD 4x3', function (err, job)) {
});