FFmpeg error will show in msgbox

This commit is contained in:
Jaex 2014-05-13 12:49:34 +03:00
parent dc00311246
commit b7e111042a
3 changed files with 14 additions and 11 deletions

View file

@ -498,5 +498,10 @@ public static string GetDescription(this Type type)
DescriptionAttribute[] attributes = (DescriptionAttribute[])type.GetCustomAttributes(typeof(DescriptionAttribute), false);
return (attributes.Length > 0) ? attributes[0].Description : type.Name;
}
public static IEnumerable<T> TakeLast<T>(this IEnumerable<T> source, int count)
{
return source.Reverse().Take(count).Reverse();
}
}
}

View file

@ -44,22 +44,19 @@ public class FFmpegHelper : ExternalCLIManager
public FFmpegHelper(ScreencastOptions options)
{
Options = options;
Helpers.CreateDirectoryIfNotExist(Options.OutputPath);
// It is actually output data
ErrorDataReceived += FFmpegCLIHelper_OutputDataReceived;
}
private void FFmpegCLIHelper_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
//DebugHelper.WriteLine(e.Data);
}
public bool Record()
{
int result = Open(Options.FFmpeg.CLIPath, Options.GetFFmpegArgs());
return result == 0;
int errorCode = Open(Options.FFmpeg.CLIPath, Options.GetFFmpegArgs());
bool result = errorCode == 0;
if (Options.FFmpeg.ShowError && !result)
{
string text = string.Join("\r\n", Errors.ToString().Lines().Where(x => !string.IsNullOrEmpty(x)).TakeLast(10).ToArray());
MessageBox.Show(text, "ShareX - FFmpeg error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
return result;
}
public static DialogResult DownloadFFmpeg(bool async, DownloaderForm.DownloaderInstallEventHandler installRequested)

View file

@ -40,6 +40,7 @@ public class FFmpegOptions
public string Extension { get; set; }
public string CLIPath { get; set; }
public string UserArgs { get; set; }
public bool ShowError { get; set; }
// H.264 - x264
public FFmpegPreset Preset { get; set; }