Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. [FunctionName("ToConvertFileFunction")]
  2. public static void Run([BlobTrigger("input/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
  3. {
  4. trace = log;
  5. trace.LogInformation($"ConvertFile function processed blobn Name:{name} n Size: {myBlob.Length} Bytes");
  6. var output = "";
  7. var error = "";
  8.  
  9. var videoTempDir = string.Format(Path.GetDirectoryName("D:\home\site\wwwroot\tempfiles\"));
  10. var videoTempFile = name + ".MOV";
  11. string videoTemp = Path.Combine(videoTempDir, videoTempFile);
  12.  
  13. using (var ms = new MemoryStream())
  14. {
  15. myBlob.CopyTo(ms);
  16. File.WriteAllBytes(videoTemp, ms.ToArray());
  17. }
  18.  
  19. var process = new Process();
  20. process.StartInfo.FileName = Environment.GetEnvironmentVariable("ffprobePath");
  21. process.StartInfo.Arguments = $"-v quiet -print_format json -show_entries stream_tags:format_tags -i {videoTemp}";
  22. process.StartInfo.RedirectStandardOutput = true;
  23. process.StartInfo.RedirectStandardError = true;
  24. process.StartInfo.UseShellExecute = false;
  25.  
  26. process.Start();
  27. trace.LogInformation("***Checking metadata***");
  28.  
  29. while (!process.StandardOutput.EndOfStream)
  30. {
  31. output += process.StandardOutput.ReadLine();
  32. }
  33.  
  34. while (!process.StandardError.EndOfStream)
  35. {
  36. error += process.StandardError.ReadLine();
  37. }
  38. process.WaitForExit();
  39.  
  40. trace.LogInformation($"ffprobe output: {output}");
  41. trace.LogInformation($"ffprobe error: {error}");
  42.  
  43. //Delete temp file
  44. File.Delete(videoTemp);
  45.  
  46. trace.LogInformation("Done!");
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement