Dev camp2012jpn day2session2

742 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
742
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Dev camp2012jpn day2session2

  1. 1. Developer Camp2012 Japan Fall10.4 Thu – 5 Fri渋谷ヒカリエ
  2. 2. マルチデバイスへの動画配信サービス ~ Windows AzureMedia Services とは ~日本マイクロソフト株式会社通信メディア統括本部ソリューションスペシャリスト畠山 大有
  3. 3. 本セッションの目的• Windows Azure Media Services で 動画配信アプリケーションを開発する方法を理解します。• 動画配信そのものについては取り扱いません。• 本セッションは、2012年6月リリースの public beta の仕様 に基づきます。今後、予告なく変更される可能性が ありますのでご注意ください。Developer Camp | 2012 Japan Fall
  4. 4. 本日の内容• Windows Azure Media Services を知る• Windows Azure Media Services 開発の ”イロハ”Developer Camp | 2012 Japan Fall
  5. 5. Windows Azure Media Servicesを知る
  6. 6. Windows Azure Media Services• 拡張可能なマルチテナントのメディア配信 プラットフォーム• クラウド上への Microsoft Media Platform 実装• パートナーエコシステム • エンコーディング/パッケージング • セキュリティ • マルチデバイス • オンデマンド / ライブ • REST APIDeveloper Camp | 2012 Japan Fall
  7. 7. 動画配信のワークフロー Windows Azure Media ServicesDeveloper Camp | 2012 Japan Fall
  8. 8. パートナーエコシステム ISV Encoding/ Content Origin & Ingest Transcoding Protection CDNDeveloper Camp | 2012 Japan Fall
  9. 9. アーキテクチャ (VOD) Windows Azure Media Services Compute StorageDeveloper Camp | 2012 Japan Fall
  10. 10. Windows Azure Media Services開発の”イロハ”
  11. 11. コードを書く前に必要な事Developer Camp | 2012 Japan Fall
  12. 12. Media Services アカウント作成Developer Camp | 2012 Japan Fall
  13. 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.aspxDeveloper Camp | 2012 Japan Fall
  14. 14. Visual Studio の設定• アセンブリ参照 • Microsoft.WindowsAzure.MediaServices.Management.Sdk.dll • %ProgramFiles(x86)%¥Microsoft SDKs¥Windows Azure Media Services¥Services¥v1.0Developer Camp | 2012 Japan Fall
  15. 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. 16. Media Services SDK for .NET Microsoft.WindowsAzure.MediaServices.Client. CloudMediaContext サービスとのセッション Assets コンテンツの集合体(ファイル) Jobs / Tasks エンコードなどのメディア処理 MediaProcessors メディア処理アプリ定義 Locators 配布/配信ポイント AccessPolicies 配布/配信 公開ポリシーDeveloper Camp | 2012 Japan Fall
  17. 17. コーディングの流れDeveloper Camp | 2012 Japan Fall
  18. 18. Ingest – Processing – Delivery : sample codeDemo
  19. 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. 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 EncryptionDeveloper Camp | 2012 Japan Fall
  21. 21. Ingest – sample code Ingest context.Assets.OnUploadProgress += new EventHandler<UploadProgressEventArgs>(Assets_OnUploadProgress); IAsset ingestAsset = context.Assets.Create(@"D:¥MediaServices¥Contents¥file.wmv“, AssetCreationOptions.StorageEncrypted); void Assets_OnUploadProgress(object sender, UploadProgressEventArgs e) { Console.WriteLine(" 経過{0:0.0}%", e.Progress); }Developer Camp | 2012 Japan Fall
  22. 22. 爆速 AsperaVideo
  23. 23. Manage Ingest • Asset / Job / AccessPolicy の管理 • 実際には Windows Azure SQL database 上で管理 • LINQ サポート • 注意点 • オブジェクトのリファレンスは自動リフレッシュ しないため、都度、再クエリが必要Developer Camp | 2012 Japan Fall
  24. 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
  25. 25. Process Ingest • エンコードなどのメディア処理の実行単位 • Job に、n個 の Task を作成 Input Asset • Job がコマンド発行の単位 • 開始/キャンセル/終了/エラーなど Task Output • 入力/出力ファイル Asset Job • 処理は非同期で Input Asset • ファイル同士の依存関係がないと Task Task は並列実行。あると直列実行 Output AssetDeveloper Camp | 2012 Japan Fall
  26. 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. 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. 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. 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_processorDeveloper Camp | 2012 Japan Fall
  30. 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. 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
  32. 32. Delivery Ingest • ストリーミング / ダウンロード のオリジンサーバー • Locator に Asset 単位で割り当てる • 1 つの Asset につき 5つの Locator が上限 • AccessPolicyによって、時間単位での公開を設定 • アクセス権設定ではないDeveloper Camp | 2012 Japan Fall
  33. 33. Delivery – sample code Ingest IAccessPolicy accessPolicy = context.AccessPolicies.Create("Streaming", TimeSpan.FromHours(3), AccessPermissions.Read | AccessPermissions.List); /// *** 配信サーバー設定 ILocator SS_StreamingPointLocator = context.Locators.CreateOriginLocator(job.OutputMediaAssets[0], accessPolicy); string SS_StreaingPointPath = SS_StreamingPointLocator.Path + (from ism in job.OutputMediaAssets[0].Files where ism.Name.EndsWith(".ism") select ism).FirstOrDefault().Name + "/manifest";Developer Camp | 2012 Japan Fall
  34. 34. Windows 8, Mac OS, iOS へ 配信Demo
  35. 35. Live Origin / Delivery (TAP) • IIS Media Services 4.1 ベース • 状態管理 • Allocation – Start / Stop / Shutdown • ヘルスチェック • アーカイブ • Blob Storage へ • IP FilteringDeveloper Camp | 2012 Japan Fall
  36. 36. Live Origin - DeliveryDemo
  37. 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. 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.aspxDeveloper Camp | 2012 Japan Fall
  39. 39. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part ofMicrosoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
  40. 40. Media Services SDK
  41. 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 GitHubDeveloper Camp | 2012 Japan Fall
  42. 42. On-Demand Workflow • Ingest • Encode • Package • Encrypt • DeliverDeveloper Camp | 2012 Japan Fall
  43. 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 supportDeveloper Camp | 2012 Japan Fall
  44. 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’ encodersDeveloper Camp | 2012 Japan Fall
  45. 45. PackageDeveloper Camp | 2012 Japan Fall
  46. 46. EncryptDeveloper Camp | 2012 Japan Fall
  47. 47. DeliverDeveloper Camp | 2012 Japan Fall
  48. 48. Target MP4Developer Camp | 2012 Japan Fall
  49. 49. API EntitiesDeveloper Camp | 2012 Japan Fall
  50. 50. Assets The logical unit that represents a single audiovisual presentation in Media Services An asset contains a collection of one to many media filesDeveloper Camp | 2012 Japan Fall
  51. 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. 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 EncoderDeveloper Camp | 2012 Japan Fall
  53. 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. 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 defaultDeveloper Camp | 2012 Japan Fall
  55. 55. Files Actual video, audio, image, or metadata blobs stored in your Azure storage account Source files are often referred to as “Mezzanine” filesDeveloper Camp | 2012 Japan Fall
  56. 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. 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 outputsDeveloper Camp | 2012 Japan Fall
  58. 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-useDeveloper Camp | 2012 Japan Fall
  59. 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 parallelDeveloper Camp | 2012 Japan Fall

×