mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-14 02:04:14 +01:00
Merge pull request #139 from rosenbjerg/dev/include-ffmpeg-stdout-in-exception
Include ffmpeg std output in exception
This commit is contained in:
commit
fa49e137f5
4 changed files with 13 additions and 12 deletions
|
@ -14,14 +14,16 @@ public enum FFMpegExceptionType
|
||||||
public class FFMpegException : Exception
|
public class FFMpegException : Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
public FFMpegException(FFMpegExceptionType type, string? message = null, Exception? innerException = null, string ffMpegErrorOutput = "")
|
public FFMpegException(FFMpegExceptionType type, string? message = null, Exception? innerException = null, string ffmpegErrorOutput = "", string ffmpegOutput = "")
|
||||||
: base(message, innerException)
|
: base(message, innerException)
|
||||||
{
|
{
|
||||||
FFMpegErrorOutput = ffMpegErrorOutput;
|
FfmpegOutput = ffmpegOutput;
|
||||||
|
FfmpegErrorOutput = ffmpegErrorOutput;
|
||||||
Type = type;
|
Type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FFMpegExceptionType Type { get; }
|
public FFMpegExceptionType Type { get; }
|
||||||
public string FFMpegErrorOutput { get; }
|
public string FfmpegOutput { get; }
|
||||||
|
public string FfmpegErrorOutput { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -70,7 +70,7 @@ void OnCancelEvent(object sender, EventArgs args)
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (!HandleException(throwOnError, e, instance.ErrorData)) return false;
|
if (!HandleException(throwOnError, e, instance.ErrorData, instance.OutputData)) return false;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ await Task.WhenAll(instance.FinishedRunning().ContinueWith(t =>
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (!HandleException(throwOnError, e, instance.ErrorData)) return false;
|
if (!HandleException(throwOnError, e, instance.ErrorData, instance.OutputData)) return false;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -140,13 +140,12 @@ private Instance PrepareInstance(out CancellationTokenSource cancellationTokenSo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static bool HandleException(bool throwOnError, Exception e, IReadOnlyList<string> errorData)
|
private static bool HandleException(bool throwOnError, Exception e, IReadOnlyList<string> errorData, IReadOnlyList<string> outputData)
|
||||||
{
|
{
|
||||||
if (!throwOnError)
|
if (!throwOnError)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
throw new FFMpegException(FFMpegExceptionType.Process, "Exception thrown during processing", e,
|
throw new FFMpegException(FFMpegExceptionType.Process, "Exception thrown during processing", e, string.Join("\n", errorData), string.Join("\n", outputData));
|
||||||
string.Join("\n", errorData));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OutputData(object sender, (DataType Type, string Data) msg)
|
private void OutputData(object sender, (DataType Type, string Data) msg)
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
<Version>3.0.0.0</Version>
|
<Version>3.0.0.0</Version>
|
||||||
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
<AssemblyVersion>3.0.0.0</AssemblyVersion>
|
||||||
<FileVersion>3.0.0.0</FileVersion>
|
<FileVersion>3.0.0.0</FileVersion>
|
||||||
<PackageReleaseNotes>- Fix snapshot in memory dispose exception</PackageReleaseNotes>
|
<PackageReleaseNotes>- Include ffmpeg output data in exception</PackageReleaseNotes>
|
||||||
<LangVersion>8</LangVersion>
|
<LangVersion>8</LangVersion>
|
||||||
<PackageVersion>3.2.2</PackageVersion>
|
<PackageVersion>3.2.3</PackageVersion>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<Authors>Malte Rosenbjerg, Vlad Jerca</Authors>
|
<Authors>Malte Rosenbjerg, Vlad Jerca</Authors>
|
||||||
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
|
||||||
|
|
|
@ -46,7 +46,7 @@ public static IMediaAnalysis Analyse(Stream stream, int outputCapacity = int.Max
|
||||||
}
|
}
|
||||||
var exitCode = task.ConfigureAwait(false).GetAwaiter().GetResult();
|
var exitCode = task.ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
if (exitCode != 0)
|
if (exitCode != 0)
|
||||||
throw new FFMpegException(FFMpegExceptionType.Process, $"FFProbe process returned exit status {exitCode}: {string.Join("\n", instance.OutputData)} {string.Join("\n", instance.ErrorData)}");
|
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);
|
return ParseOutput(pipeArgument.PipePath, instance);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public static async Task<IMediaAnalysis> AnalyseAsync(Stream stream, int outputC
|
||||||
}
|
}
|
||||||
var exitCode = await task;
|
var exitCode = await task;
|
||||||
if (exitCode != 0)
|
if (exitCode != 0)
|
||||||
throw new FFMpegException(FFMpegExceptionType.Process, $"FFProbe process returned exit status {exitCode}: {string.Join("\n", instance.OutputData)} {string.Join("\n", instance.ErrorData)}");
|
throw new FFMpegException(FFMpegExceptionType.Process, $"FFProbe process returned exit status {exitCode}", null, string.Join("\n", instance.ErrorData), string.Join("\n", instance.OutputData));
|
||||||
|
|
||||||
pipeArgument.Post();
|
pipeArgument.Post();
|
||||||
return ParseOutput(pipeArgument.PipePath, instance);
|
return ParseOutput(pipeArgument.PipePath, instance);
|
||||||
|
|
Loading…
Reference in a new issue