Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [FunctionName("ToConvertFileFunction")]
- public static void Run([BlobTrigger("input/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
- {
- trace = log;
- trace.LogInformation($"ConvertFile function processed blobn Name:{name} n Size: {myBlob.Length} Bytes");
- var output = "";
- var error = "";
- var videoTempDir = string.Format(Path.GetDirectoryName("D:\home\site\wwwroot\tempfiles\"));
- var videoTempFile = name + ".MOV";
- string videoTemp = Path.Combine(videoTempDir, videoTempFile);
- using (var ms = new MemoryStream())
- {
- myBlob.CopyTo(ms);
- File.WriteAllBytes(videoTemp, ms.ToArray());
- }
- var process = new Process();
- process.StartInfo.FileName = Environment.GetEnvironmentVariable("ffprobePath");
- process.StartInfo.Arguments = $"-v quiet -print_format json -show_entries stream_tags:format_tags -i {videoTemp}";
- process.StartInfo.RedirectStandardOutput = true;
- process.StartInfo.RedirectStandardError = true;
- process.StartInfo.UseShellExecute = false;
- process.Start();
- trace.LogInformation("***Checking metadata***");
- while (!process.StandardOutput.EndOfStream)
- {
- output += process.StandardOutput.ReadLine();
- }
- while (!process.StandardError.EndOfStream)
- {
- error += process.StandardError.ReadLine();
- }
- process.WaitForExit();
- trace.LogInformation($"ffprobe output: {output}");
- trace.LogInformation($"ffprobe error: {error}");
- //Delete temp file
- File.Delete(videoTemp);
- trace.LogInformation("Done!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement