Home

Awesome

scriptcs-azuremediaservices

Windows Azure Media Services Script Pack

What is it?

Script pack for accessing Azure Media Services from scriptcs CSX script and scriptcs REPL.

Usage

Install the nuget package by running scriptcs -install ScriptCs.AzureMediaServices.

Creating the Azure Media Services Client

var mediaServices = Require<AzureMediaServices>();

var client = mediaServices.CreateClient("mediaServicesAccountName", "mediaServicesAccountKey");

Working with Assets

Getting all assets

var assets = client.GetAssets();

Getting assets by filter

var assets = client.GetAssets(a => a.AlternateId == "mezzanine");

Getting assets by Id

var myAsset = client.GetAsset("nb:cid:UUID:8131a85d-5999-555c-a30f-468cb087701c");

Deleting an asset

client.DeleteAsset("nb:cid:UUID:8131a85d-5999-555c-a30f-468cb087701c");

Uploading an asset

var uploader = client.CreateUploader("myAssetName", @"d:\media\videos\video.mp4");
uploader.On(
			progress: progressPercentage => Console.WriteLine(progressPercentage),
			completed: assetId => Console.WriteLine(assetId),
			error: exception => Console.WriteLine(exception.Message));
uploader.Start();

Working with Media Processors

Getting all media processors

var mediaProcessors = client.GetMediaProcessors();

Working with Jobs

Getting jobs by Job State

var jobs = client.GetJobsByState(JobState.Finished);

Getting jobs by Id

var job = client.GetJob("nb:jid:UUID:8ba5f1ca-d23d-b847-8e7a-34d1f4ce98a7");

Encoding a video (Experimental API)

// CreateEncoder expects as parameters:
//  - the name of job to be created
//  - the input asset that will be used during the encoding process
//  - the configuration or preset to be used for the encodiding process
//  - the desired name for the encoding output asset
var encoder = client.CreateEncoder("My Job Name", inputAsset, "H264 Broadband 720p", "My Output Asset Name");
encoder.On(
			processing: jobId => Console.WriteLine("Processing Job {0}", jobId),
			finished: jobId => Console.WriteLine(jobId),
			error: errorMessage => Console.WriteLine(errorMessage));
encoder.Start();

What's next