public static async Task <IMediaAnalysis> AnalyseAsync(Stream stream, int outputCapacity = int.MaxValue, FFOptions?ffOptions = null) { var streamPipeSource = new StreamPipeSource(stream); var pipeArgument = new InputPipeArgument(streamPipeSource); using var instance = PrepareInstance(pipeArgument.PipePath, outputCapacity, ffOptions ?? GlobalFFOptions.Current); pipeArgument.Pre(); var task = instance.FinishedRunning(); try { await pipeArgument.During().ConfigureAwait(false); } catch (IOException) { } finally { pipeArgument.Post(); } var exitCode = await task.ConfigureAwait(false); if (exitCode != 0) { throw new FFProbeProcessException($"ffprobe exited with non-zero exit-code ({exitCode} - {string.Join("\n", instance.ErrorData)})", instance.ErrorData); } pipeArgument.Post(); return(ParseOutput(instance)); }
public static async Task <MediaAnalysis> AnalyseAsync(System.IO.Stream stream, int outputCapacity = int.MaxValue) { var streamPipeSource = new StreamPipeSource(stream); var pipeArgument = new InputPipeArgument(streamPipeSource); using var instance = PrepareInstance(pipeArgument.PipePath, outputCapacity); pipeArgument.Pre(); var task = instance.FinishedRunning(); try { await pipeArgument.During(); } catch (IOException) { } finally { pipeArgument.Post(); } var exitCode = await task; if (exitCode != 0) { throw new FFMpegException(FFMpegExceptionType.Process, $"FFProbe process returned exit status {exitCode}: {string.Join("\n", instance.OutputData)} {string.Join("\n", instance.ErrorData)}"); } pipeArgument.Post(); return(ParseOutput(pipeArgument.PipePath, instance)); }
public static IMediaAnalysis?Analyse(Stream stream, int outputCapacity = int.MaxValue) { var streamPipeSource = new StreamPipeSource(stream); var pipeArgument = new InputPipeArgument(streamPipeSource); using var instance = PrepareInstance(pipeArgument.PipePath, outputCapacity); pipeArgument.Pre(); var task = instance.FinishedRunning(); try { pipeArgument.During().ConfigureAwait(false).GetAwaiter().GetResult(); } catch (IOException) { } finally { pipeArgument.Post(); } var exitCode = task.ConfigureAwait(false).GetAwaiter().GetResult(); if (exitCode != 0) { throw new FFMpegException(FFMpegExceptionType.Process, $"FFProbe process returned exit status {exitCode}", null, string.Join("\n", instance.ErrorData), string.Join("\n", instance.OutputData)); } return(ParseOutput(pipeArgument.PipePath, instance)); }