3. 本セッションの目的
• Windows Azure Media Services で
動画配信アプリケーションを開発する方法を理解します。
• 動画配信そのものについては取り扱いません。
• 本セッションは、2012年6月リリースの public beta の仕様
に基づきます。今後、予告なく変更される可能性が
ありますのでご注意ください。
Developer Camp | 2012 Japan Fall
4. 本日の内容
• Windows Azure Media Services を知る
• Windows Azure Media Services 開発の ”イロハ”
Developer Camp | 2012 Japan Fall
6. Windows Azure Media Services
• 拡張可能なマルチテナントのメディア配信
プラットフォーム
• クラウド上への
Microsoft Media Platform 実装
• パートナーエコシステム
• エンコーディング/パッケージング
• セキュリティ
• マルチデバイス
• オンデマンド / ライブ
• REST API
Developer Camp | 2012 Japan Fall
7. 動画配信のワークフロー
Windows Azure Media Services
Developer Camp | 2012 Japan Fall
8. パートナーエコシステム
ISV
Encoding/ Content Origin &
Ingest
Transcoding Protection CDN
Developer Camp | 2012 Japan Fall
9. アーキテクチャ (VOD)
Windows Azure Media Services
Compute
Storage
Developer Camp | 2012 Japan Fall
13. 開発環境の準備
• Windows 7, Windows 8, Windows 2008 R2
• .NET Framework 3.5 SP1, .NET Framework 4
• Visual Studio 2010 SP1
• Windows Azure SDK 1.6 (November 2011)
• Windows Azure Media Services SDK (June 2012 Preview)
• WCF Data Services 5.0 for OData V3
• http://msdn.microsoft.com/en-us/library/hh973620.aspx
Developer Camp | 2012 Japan Fall
14. Visual Studio の設定
• アセンブリ参照
• Microsoft.WindowsAzure.MediaServices.Management.Sdk.dll
• %ProgramFiles(x86)%¥Microsoft SDKs¥Windows Azure Media Services¥Services¥v1.0
Developer Camp | 2012 Japan Fall
15. Sample Player の準備
• Smooth Streaming
• Microsoft Media Platform: Player Framework
• Windows 8: http://playerframework.codeplex.com/releases/view/94684
• Silverlight: http://smf.codeplex.com/releases/view/88970
• HTML5 <video> (iOS用)
<video width="640"
height="480"
src="http://<your url>/hogehoge.mp4"
autoplay controls >
ご利用の Web ブラウザー では再生できません
</video>
Developer Camp | 2012 Japan Fall
16. Media Services SDK for .NET
Microsoft.WindowsAzure.MediaServices.Client.
CloudMediaContext サービスとのセッション
Assets コンテンツの集合体(ファイル)
Jobs / Tasks エンコードなどのメディア処理
MediaProcessors メディア処理アプリ定義
Locators 配布/配信ポイント
AccessPolicies 配布/配信 公開ポリシー
Developer Camp | 2012 Japan Fall
19. Windows Azure Media Services
接続
• Windows Azure Media Servicesとの全てのやりとりは、
CloudMediaContext クラスを通じて
• 注意点
• CloudMediaContext はスレッドセーフではない
CloudMediaContext context = new CloudMediaContext(
ConfigurationManager.AppSettings["accountName"],
ConfigurationManager.AppSettings["accountKey"]
);
Developer Camp | 2012 Japan Fall
20. Ingest
Ingest
• Asset作成 = Windows Azure Media Services 管理下に、
ファイルを置く
• ファイルのアップロード
• 別の Blob からのコピーも可能
• Asset に 書き込み可能な SAS URLを作成し、それを元に
Containerを作成する
• http://social.msdn.microsoft.com/Forums/en-US/MediaServices/thread/be486bac-ac37-4984-87d0-
20931fcb1328
• 2つの暗号化オプション: AES 256bit / Common Encryption
Developer Camp | 2012 Japan Fall
24. Manage: Asset
Ingest
• Windows Azure Blob コンテナ
• アプリケーション的なメタは持っていない
• Asset. AlternateId にてCMS連携 ID Name Title Artist
0001 Contoso Great Video Art #1
Id AlternateId Name
• 削除する際の注意点 <guid> 0001 contoso
• 関連する Locator は個別削除が必要
• AssetCreationOptions.CommonEncryptionProtected 指定をした
Asset を削除する場合は、ContentsKey の個別削除が必須
Developer Camp | 2012 Japan Fall
26. Process: Windows Azure Media Encoder
Ingest
• Expression Encoder 4 Pro SP2 がベース
• Azure に最適化
• Adaptive Bitrate Streamingでは、複数VMを使う
• タスク プリセット 指定
• http://msdn.microsoft.com/en-us/library/jj129582.aspx
• 「現在」は、Expression Encoder 4 Pro SP2 の
カスタム タスク プリセット (XML文字列) も動作する!
• サムネイル作成, 時間指定の切り出し など
Developer Camp | 2012 Japan Fall
27. Process: Windows Azure Media Encoder
Ingest
• サポートしているファイルフォーマット
• 3GPP, 3GPP2
• Advanced Systems Format (ASF)
• Advanced Video Coding High Definition (AVCHD) [MPEG-2 Transport
Stream]
• Audio-Video Interleaved (AVI)
• AviSynth
• Digital camcorder MPEG-2 (MOD)
• Digital video (DV) camera file • AC-3 (Dolby Digital) audio
• DVD transport stream (TS) file • Audio Interchange File Format (AIFF)
• DVD video object (VOB) file • Broadcast Wave Format
• Expression Encoder Screen Capture Codec file • MP3 (MPEG-1 Audio Layer 3)
• MP4
• MP4 audio
• MPEG-1 System Stream
• MPEG-2 video file • MPEG-4 audio book
• Smooth Streaming File Format (PIFF 1.3) • WAVE file
• Windows Media Video (WMV) • Windows Media Audio
ビデオ オーディオ
Developer Camp | 2012 Japan Fall
28. Process: Windows Azure Media Encoder
Ingest
• サポートしているコーデック
• H.264
• MPEG-1 • AC-3 (Dolby Digital audio)
• MPEG-2 • Advanced Audio Coding (AAC)
• VC-1 • MP3 (MPEG-1 Audio Layer 3)
• Windows Media Video • Windows Media Audio
ビデオ オーディオ
Developer Camp | 2012 Japan Fall
29. Process: Windows Azure Media Packager / Encryptor
Ingest
• IIS Transform Manager 1.0 がベース
• http://msdn.microsoft.com/en-us/library/hh973619.aspx
• Media Processor 定義 + 設定XML文字列
• PlayReady Protection Task
• MP4 to Smooth Streams Task
• Smooth Streams to HLS Conversion Task
• Storage Decyption
• http://msdn.microsoft.com/en-us/library/jj129580.aspx#get_media_processor
Developer Camp | 2012 Japan Fall
30. Process – sample code (1)
Ingest
IJob job = context.Jobs.Create("WMV to SS and HLS");
IMediaProcessor windowsAzureMediaEncoder = (from a in context.MediaProcessors
where a.Name == “Windows Azure Media Encoder”
select a).First();
ITask WMS2SSTask = job.Tasks.AddNew("WMV to Smooth Streaming",
windowsAzureMediaEncoder,
"H.264 IIS Smooth Streaming iPhone WiFi",
TaskCreationOptions.None);
// 入出力ファイル
WMS2SSTask.InputMediaAssets.Add(ingestAsset);
IAsset SSedAssed = WMS2SSTask.OutputMediaAssets.AddNew(”SmoothStreaming",
true,
AssetCreationOptions.None);
job.Submit();
Developer Camp | 2012 Japan Fall
31. Process – sample code (2)
Ingest
bool jobFinalize = false;
while (!jobFinalize) {
job = (from j in context.Jobs
where j.Id == job.Id
select j).FirstOrDefault();
Console.WriteLine(" ***: {0}", job.State.ToString());
switch (job.State) {
case JobState.Finished:
jobFinalize = true;
Console.WriteLine(" 正常終了: {0}", job.RunningDuration);
break;
case JobState.Error:
jobFinalize = true;
Console.WriteLine(" エラー発生: {0}", job.Tasks[0].ErrorDetails);
break;
default:
Console.WriteLine(" 15秒間 待機します: {0}", DateTime.Now.ToLongTimeString());
System.Threading.Thread.Sleep(15000);
break;
}
}
Developer Camp | 2012 Japan Fall
37. まとめ
Quick and Easy
シンプルなAPI
PaaS
Open and Flexible
様々な Partner Application
様々なAPI: REST, .NET, Java, PHP
Powerful and Cost Effective
進化し続けるCloud インフラのメリットを直接共有
Capex / Opex の最小化
Developer Camp | 2012 Japan Fall
38. ご参考リソース
• MSDN Online: Windows Azure Media Services:
• http://msdn.microsoft.com/en-us/library/hh973629.aspx
• ScottGu’s Blog: Windows Azure Media Services and London
2012 Olympics
• http://weblogs.asp.net/scottgu/archive/2012/08/21/windows-azure-
media-services-and-the-london-2012-olympics.aspx
Developer Camp | 2012 Japan Fall
41. Media Services APIs and SDKs
• REST API for all platforms, using OData 3.0
Simple to write your own client libraries using REST API and
standard HTTP verbs (GET, POST, PUT, DELETE)
•
•
.NET library available in Preview
Future - JAVA library available in Fall
• Open Libraries available with source code (Apache 2 license) on GitHub
Developer Camp | 2012 Japan Fall
42. On-Demand Workflow
• Ingest
• Encode
• Package
• Encrypt
• Deliver
Developer Camp | 2012 Japan Fall
43. Ingest
Ingest Assets into the Media Services
Pre-encrypt files prior to uploading(AES 256)
Secure HTTPS upload
Network level peering for fast HTTP into Azure
Fast upload using UDP with Aspera
Bulk ingest support
Developer Camp | 2012 Japan Fall
44. Encode
Windows Azure Media Encoder
Supports encoding to H.264 or VC-1 video
Encodes audio to AAC-LC, HE-AAC, Dolby DD+, WMA
Packages to MP4, HLS, Smooth Streaming, HDS, WMV
Encrypts with PlayReady, Common Encryption, AES
Encoding with third-parties
Partner SDK for enabling ‘build-in’ encoders
Developer Camp | 2012 Japan Fall
50. Assets
The logical unit that represents a single
audiovisual presentation in Media Services
An asset contains a collection of one to many
media files
Developer Camp | 2012 Japan Fall
51. An Asset Is….
• An asset should be considered a single version
or derivative of an audiovisual presentation
• Examples:
• a full movie, TV show, specific edit
• a clip from a movie, TV show, animation, camera ISO
file, event, etc..
• a movie trailer or promotional video
• an advertisement
• an audio file, radio show, podcast, sound file, etc…
Developer Camp | 2012 Japan Fall
52. An Asset Is NOT….
• A folder to organize and store multiple
versions of the same presentation in
• For example, you would never use an Asset to
store the Movie, its trailer, an advertisement,
and an international edit version of the same
movie in a single Asset
•
A folder for submitting batch processing of
multiple audiovisual presentations to
Azure Media Encoder
Developer Camp | 2012 Japan Fall
53. Access Policies
Access Policies define the permissions and duration of
access to an Asset
Controls Read/Write semantics
Controls duration in minutes that a URL has access
Future expansion for more policy settings; IP white-
listing, Geo-restriction, Identity/Group access, etc…
Developer Camp | 2012 Japan Fall
54. Content Keys
Encryption information (AES Content Key,
X.509 certificate) for protected assets
Assets can be either:
“storage encrypted” (256-bit key) to protect them at
rest
“common encrypted” (128-bit key) for DRM delivery.
Assets are storage encrypted by default
Developer Camp | 2012 Japan Fall
55. Files
Actual video, audio, image, or metadata
blobs stored in your Azure storage account
Source files are often referred to as
“Mezzanine” files
Developer Camp | 2012 Japan Fall
56. Locators
A Locator is a URI that provides time-based access
to a specific asset
It is used with an AccessPolicy to define the
permissions and duration that a client has access to
a given Asset
Locators can be used to generate SAS URLs, Origin
Server URLs , CDN URLs, 3rd party origin URLs, etc…
Developer Camp | 2012 Japan Fall
57. Jobs
A job is an “workflow” in Media Services that
can be scheduled, monitored and canceled
The Job entity holds metadata about Tasks,
which do processing on the files in an Asset
A job always has one or more associated
inputs, tasks, and outputs
Developer Camp | 2012 Japan Fall
58. Job Templates
A JobTemplate provides reusable
settings for Jobs that need to be run
repeatedly
JobTemplates can be saved from
existing Jobs for re-use
Developer Camp | 2012 Japan Fall
59. Tasks
A Task is an individual operation of work on an
Asset and is defined in a Job
Tasks point to “Media Processors” that can be
either first or third party
Each Task has its own configuration and can be
scheduled to run sequentially or in parallel
Developer Camp | 2012 Japan Fall