Windows Azure メディアサービスでバージョンを指定して MediaProcessor を取得する方法
Window Azure メディアサービスでは、用意されたエンコーダやエンクリプタを利用して、動画のエンコーディングや暗号化が可能だ。今回はサンプルコードベースでバージョンを指定した MediaProcessor の取得方法を紹介する。
サンプルコードと実行結果
さっそくサンプルコードを紹介する。NuGet から Windows Azure Media Service のSDKを取得後、以下のコードを作成する
using Microsoft.WindowsAzure.MediaServices.Client; using System; using System.IO; using System.Linq; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { CloudMediaContext context = new CloudMediaContext("<アカウント名>", "<アカウントキー>"); Console.WriteLine("Media Processor 一覧"); foreach (var mediaProcessor in context.MediaProcessors) { Console.WriteLine(string.Join(",", new object[]{ mediaProcessor.Id, mediaProcessor.Name, mediaProcessor.Vendor, mediaProcessor.Version })); } Console.WriteLine(""); // OrderBy 内の Version 操系で NotSupportedException がでるので、直前で ToList() Console.WriteLine("最新の Windows Azure Media Encoder だけ取得"); var mediaEncoderVerCurrent = context.MediaProcessors.ToList() .OrderByDescending(wame => new Version(wame.Version)).FirstOrDefault(); Console.WriteLine(string.Join(",", new object[]{ mediaEncoderVerCurrent.Id, mediaEncoderVerCurrent.Name, mediaEncoderVerCurrent.Vendor, mediaEncoderVerCurrent.Version })); Console.WriteLine(""); Console.WriteLine("特定の Windows Azure Media Encoder だけ取得"); // OrderBy 内の Version 操系で NotSupportedException がでるので、直前で ToList() var mediaEncoderVer23 = context.MediaProcessors.ToList() .FirstOrDefault(wame => new Version(wame.Version) == new Version("2.3")); Console.WriteLine(string.Join(",", new object[]{ mediaEncoderVer23.Id, mediaEncoderVer23.Name, mediaEncoderVer23.Vendor, mediaEncoderVer23.Version })); Console.ReadKey(); } } }
上記の実行結果は以下となる。エンコーダやエンクリプタの他、ストレージの複合化やパッケージング用の Media Processor もあるらしい。この辺りは Process Assets with the Media Services SDK for .NET - Accessing a Media Processor を参照してほしい。
Media Processor 一覧 nb:mpid:UUID:70bdc2c3-ebf4-42a9-8542-5afc1e55d217,Windows Azure Media Encoder,Microsoft,2.3 nb:mpid:UUID:38a620d8-b8dc-4e39-bb2e-7d589587232b,Windows Azure Media Encryptor,Microsoft,2.4 nb:mpid:UUID:aec03716-7c5e-4f68-b592-f4850eba9f10,Storage Decryption,Microsoft,1.7 nb:mpid:UUID:a2f9afe9-7146-4882-a5f7-da4a85e06a93,Windows Azure Media Packager,Microsoft,2.4 nb:mpid:UUID:2e7aa8f3-4961-4e0c-b4db-0e0439e524f5,Windows Azure Media Encoder,Microsoft,3.1 最新の Windows Azure Media Encoder だけ取得 nb:mpid:UUID:2e7aa8f3-4961-4e0c-b4db-0e0439e524f5,Windows Azure Media Encoder,Microsoft,3.1 特定の Windows Azure Media Encoder だけ取得 nb:mpid:UUID:70bdc2c3-ebf4-42a9-8542-5afc1e55d217,Windows Azure Media Encoder,Microsoft,2.3