mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
FFmpeg error will show in msgbox
This commit is contained in:
parent
dc00311246
commit
b7e111042a
3 changed files with 14 additions and 11 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue