Beispiel #1
0
        public async Task UploadRandomBlob()
        {
            //arrange

            string videoFile = config.GetValue <string>("videoFile");

            //act
            BlobHelper.CreateStorageConnection(config.GetValue <string>("rawStorageConnectionString"), config.GetValue <string>("rawContainerRef"));
            await BlobHelper.UploadSummary(videoFile, newVideoId, log);

            var getBlobList = await BlobHelper.GetBlobList(log);

            var res = getBlobList.Results.Where(x => ((CloudBlockBlob)x).Name == newVideoId).FirstOrDefault();

            // assert
            Assert.AreEqual(newVideoId, ((CloudBlockBlob)res).Name);
        }
Beispiel #2
0
        public static async Task Run([ActivityTrigger] DurableActivityContext inputs, ILogger log)
        {
            log.LogInformation($"Runner Started");
            //ToDo - Fix getting info from Event
            (string correlationId, string assetId)eventData = inputs.GetInput <(string, string)>();
            string jobId = eventData.correlationId;
            //Create a Unique working directory
            string workingDir = Directory.CreateDirectory(DirectoryPath + jobId).FullName.ToString();

            log.LogInformation($"Created directory {workingDir}");
            //Create collection for list of png files
            List <string> localBlobs = new List <string>();
            //Create a unique output name for video summary file
            //string outputName = $"summary-{jobId}.mp4";
            string outputName = $"summary-{jobId}.jpg";

            //Create a blob client to the AMS account and asset container created by the encoding Job
            BlobHelper.CreateStorageConnection(AMSStorageConnectionString, $"asset-{eventData.assetId}");
            log.LogInformation($"Created Storage Connection");
            try
            {
                //MSI could be used in future when blob AAD access is out of preview
                ////Get MSI Token from Function Host
                //var azureServiceTokenProvider = new AzureServiceTokenProvider();
                //string accessToken = await azureServiceTokenProvider.GetAccessTokenAsync(ArmEndpoint);
                //ServiceClientCredentials credentials = new TokenCredentials(accessToken);
                //Get list of thumnails
                localBlobs = await GetThumbnails(workingDir, log);

                var trimBlobId = TrimBlobId(localBlobs[0]);
                //string summaryArgs = $"-v quiet -r 1/5 -i {trimBlobId}%06d.png -c:v libx264 -vf fps=25 -pix_fmt yuv420p {outputName}";
                string summaryArgs = $"-v quiet -i {trimBlobId}%06d.png -filter_complex tile=1x{localBlobs.Count} {outputName}";
                var    summaryId   = FFMpeg.RunFFMpeg(workingDir, ffmpegLocation, summaryArgs, eventData.correlationId, log);
                await BlobHelper.UploadSummary(Path.Combine(workingDir, outputName), outputName, log);
            }
            catch (Exception ex)
            {
                log.LogError($"Status: Error with Function init: {ex.Message}, CorrelationId: {eventData.correlationId}");
                throw;
            }
            finally
            {
                Directory.Delete(workingDir, true);
            }
        }