2017-12-15 3 views
0

Azure Media Services에서 .mp4 비디오를 업로드 할 수있는 응용 프로그램을 구현해야합니다. 동영상은 ProgressiveDownload 스트리밍 형식으로 게시해야하며 으로 암호화되어야합니다.ProgressiveDownload 스트리밍 형식의 미디어 서비스에 비디오 게시

미디어 서비스 설명서 공부 콘솔 응용 프로그램을 구현하려고했습니다.

static void Main(string[] args) 
    { 
     try 
     { 
      var tokenCredentials = new AzureAdTokenCredentials(_AADTenantDomain, AzureEnvironments.AzureCloudEnvironment); 
      var tokenProvider = new AzureAdTokenProvider(tokenCredentials); 

      _context = new CloudMediaContext(new Uri(_RESTAPIEndpoint), tokenProvider); 

      // Add calls to methods defined in this section. 
      // Make sure to update the file name and path to where you have your media file. 
      IAsset inputAsset = 
      UploadFile(_videoPath, AssetCreationOptions.StorageEncrypted); 

      IAsset encodedAsset = 
      EncodeToAdaptiveBitrateMP4s(inputAsset, AssetCreationOptions.StorageEncrypted); 

      PublishAssetGetURLs(encodedAsset); 
     } 
     catch (Exception exception) 
     { 
      // Parse the XML error message in the Media Services response and create a new 
      // exception with its content. 
      exception = MediaServicesExceptionParser.Parse(exception); 

      Console.Error.WriteLine(exception.Message); 
     } 
     finally 
     { 
      Console.ReadLine(); 
     } 
    }  

    static public IAsset EncodeToAdaptiveBitrateMP4s(IAsset asset, AssetCreationOptions options) 
    { 

     // Prepare a job with a single task to transcode the specified asset 
     // into a multi-bitrate asset. 

     IJob job = _context.Jobs.CreateWithSingleTask(
      "Media Encoder Standard", 
      "Adaptive Streaming", 
      asset, 
      "Adaptive Bitrate MP4", 
      options); 

     Console.WriteLine("Submitting transcoding job..."); 


     // Submit the job and wait until it is completed. 
     job.Submit(); 

     job = job.StartExecutionProgressTask(
      j => 
      { 
       Console.WriteLine("Job state: {0}", j.State); 
       Console.WriteLine("Job progress: {0:0.##}%", j.GetOverallProgress()); 
      }, 
      CancellationToken.None).Result; 

     Console.WriteLine("Transcoding job finished."); 

     IAsset outputAsset = job.OutputMediaAssets[0]; 

     return outputAsset; 
    } 

    static public void PublishAssetGetURLs(IAsset asset) 
    { 
     // Publish the output asset by creating an Origin locator for adaptive streaming, 
     // and a SAS locator for progressive download. 

     IAssetDeliveryPolicy policy = 
      _context.AssetDeliveryPolicies.Create("Clear Policy", 
      AssetDeliveryPolicyType.NoDynamicEncryption, 
      AssetDeliveryProtocol.ProgressiveDownload | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash, 
      null); 

     asset.DeliveryPolicies.Add(policy); 

     _context.Locators.Create(
      LocatorType.OnDemandOrigin, 
      asset, 
      AccessPermissions.Read, 
      TimeSpan.FromDays(30)); 

     _context.Locators.Create(
      LocatorType.Sas, 
      asset, 
      AccessPermissions.Read, 
      TimeSpan.FromDays(30)); 


     IEnumerable<IAssetFile> mp4AssetFiles = asset 
       .AssetFiles 
       .ToList() 
       .Where(af => af.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)); 

     // Get the Smooth Streaming, HLS and MPEG-DASH URLs for adaptive streaming, 
     // and the Progressive Download URL. 
     Uri smoothStreamingUri = asset.GetSmoothStreamingUri(); 
     Uri hlsUri = asset.GetHlsUri(); 
     Uri mpegDashUri = asset.GetMpegDashUri(); 

     // Get the URls for progressive download for each MP4 file that was generated as a result 
     // of encoding. 
     List<Uri> mp4ProgressiveDownloadUris = mp4AssetFiles.Select(af => af.GetSasUri()).ToList();      
    } 

나머지 부분을 암호화 관리하는 부분을 추가하면이 코드가 작동하지 않습니다. 나는 때 더 정확하게 :

  • UploadFile(_videoPath, AssetCreationOptions.StorageEncrypted);UploadFile(_videoPath, AssetCreationOptions.None);을 대체
  • EncodeToAdaptiveBitrateMP4s(inputAsset, AssetCreationOptions.StorageEncrypted);
  • EncodeToAdaptiveBitrateMP4s(inputAsset, AssetCreationOptions.None); 교체는 PublishAssetGetURLs 방법

    IAssetDeliveryPolicy 정책 = _context.AssetDeliveryPolicies.Create ("클리어 정책에 다음 코드를 추가 ", AssetDeliveryPolicyType.NoDynamicEncryption, AssetDeliveryProtocol.Progress iveDownload | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash, null);

    asset.DeliveryPolicies.Add(policy); 
    

문제는 비디오가 제대로 업로드되었는지,하지만 난 잘 푸른 포털 내에서 비디오를 재생하려고하면 나는 일반적인 0x0으로 오류가 발생합니다.

+0

질문 - 안심하고 콘텐츠를 보호하고 암호화하고 싶지만 보호되지 않은 콘텐츠에 URL을 나누어주고 콘텐츠를 깨끗하게 스트리밍 하시겠습니까? 정확히 어떤 시나리오를 해결하고 있습니까? 콘텐츠가 도난 당하거나 불법으로 유출 될 우려가 있습니까? 그렇다면 왜 콘텐츠를 Clear로 게시해야합니까? 저장소 암호화는 기본적으로 DRM을 사용하고 MPAA 지침을 충족해야하는 고객을위한 기능입니다. 스토리지 암호화가 필요한 경우 Storage 계정에서 서버 측 스토리지 암호화를 켜고 일반 텍스트로 업로드하십시오. – johndeu

+0

실제로 요구 사항은 보호 된 콘텐츠를 전달하는 것이며, 이전에 Smooth Streaming과 Dynamic Encryption을 통해 구현 된 것입니다. 솔루션은 작동하지만 불행히도 동적 암호화를 허용하지 않는 프로그레시브 다운로드를 고려해야하는 다른 기술적 문제에 직면하고 있습니다. – user2297037

답변

0

ID를 보호해야하는 경우 점진적 다운로드를 피하십시오. 오프라인으로 보호되는 다운로드 솔루션을 만드는 경우가 아니라면 이 경우 우리는 우리의 문서에서 Playready, Widevine 및 Fairpoay 오프라인 DRM을 수행하는 방법을 보여주는 새로운 기사를 추가했습니다. 해당 기사에 대한 문서의 콘텐츠 보호 섹션을 확인하십시오.