Saving video to azure, unable to load video some times

Dec 15 2017 6:49 AM
Hello all I am having the following code to save video to azure, which is working fine. But when I am loading the videos and trying to play them I am unable to play some of them. I am calling this using a service to execute for every 2 seconds to record the video from the angular service
  1. public async Task<int> Save(System.IO.Stream stream, string name)  
  2. {  
  3.     MemoryStream memStream = new MemoryStream();  
  4.     stream.CopyTo(memStream);  
  5.     memStream.Position = 0;  
  6.     // Parse the connection string and return a reference to the storage account.  
  7.     CloudStorageAccount storageAccount = CloudStorageAccount.Parse(AzureConfig.CONNECTION_STRING);  
  8.     CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();  
  9.     ServiceProperties serviceProperties = await blobClient.GetServicePropertiesAsync();  
  10.         // Set the default service version to be used for anonymous requests.  
  11.      serviceProperties.DefaultServiceVersion = "2016-05-31";  
  12.         // Set the service properties.  
  13.      await blobClient.SetServicePropertiesAsync(serviceProperties);  
  14.         // Retrieve a reference to a container.  
  15.     CloudBlobContainer container = blobClient.GetContainerReference("video");  
  16.         // Retrieve reference to a blob named "myblob".  
  17.     CloudAppendBlob appBlob = container.GetAppendBlobReference(name + ".webm");  
  18.     if (!await appBlob.ExistsAsync())  
  19.     {  
  20.         await appBlob.CreateOrReplaceAsync();  
  21.     }  
  22.     appBlob.Properties.ContentType = "video/webm;codecs=vp9";  
  23.     await appBlob.SetPropertiesAsync();  
  24.   
  25.     appBlob.Metadata.Add(new KeyValuePair<stringstring>("uploadedDate", DateTime.Now.ToString()));  
  26.   
  27.     await appBlob.AppendFromStreamAsync(memStream);  
  28.   
  29.     return 0;  
  30. }  
The video is getting uploaded but when I am trying to view the video some times the video is not getting displayed. I am using similar kind of this where for every 2 seconds I am calling a service to save the video in to azure
 
https://www.webrtc-experiment.com/RecordRTC/

Answers (1)