mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 10:19:07 +00:00
deal with CreateProcess failure
This commit is contained in:
@@ -137,25 +137,31 @@ namespace QuickLook.Plugin.ImageViewer.Exiv2
|
|||||||
|
|
||||||
private Dictionary<string, string> Run(string arg, string regexSplit)
|
private Dictionary<string, string> Run(string arg, string regexSplit)
|
||||||
{
|
{
|
||||||
string result;
|
try
|
||||||
|
|
||||||
using (var p = new Process())
|
|
||||||
{
|
{
|
||||||
p.StartInfo.UseShellExecute = false;
|
string result;
|
||||||
p.StartInfo.CreateNoWindow = true;
|
using (var p = new Process())
|
||||||
p.StartInfo.RedirectStandardOutput = true;
|
{
|
||||||
p.StartInfo.FileName = ExivPath;
|
p.StartInfo.UseShellExecute = false;
|
||||||
p.StartInfo.Arguments = arg;
|
p.StartInfo.CreateNoWindow = true;
|
||||||
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
p.StartInfo.RedirectStandardOutput = true;
|
||||||
p.Start();
|
p.StartInfo.FileName = ExivPath;
|
||||||
|
p.StartInfo.Arguments = arg;
|
||||||
|
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||||
|
p.Start();
|
||||||
|
|
||||||
result = p.StandardOutput.ReadToEnd();
|
result = p.StandardOutput.ReadToEnd();
|
||||||
p.WaitForExit(1000);
|
p.WaitForExit(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.IsNullOrWhiteSpace(result)
|
||||||
|
? new Dictionary<string, string>()
|
||||||
|
: ParseResult(result, regexSplit);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.IsNullOrWhiteSpace(result)
|
|
||||||
? new Dictionary<string, string>()
|
|
||||||
: ParseResult(result, regexSplit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, string> ParseResult(string result, string regexSplit)
|
private Dictionary<string, string> ParseResult(string result, string regexSplit)
|
||||||
|
@@ -40,28 +40,35 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
|
|||||||
|
|
||||||
private bool Run(string media)
|
private bool Run(string media)
|
||||||
{
|
{
|
||||||
string result;
|
try
|
||||||
|
|
||||||
using (var p = new Process())
|
|
||||||
{
|
{
|
||||||
p.StartInfo.UseShellExecute = false;
|
string result;
|
||||||
p.StartInfo.CreateNoWindow = true;
|
|
||||||
p.StartInfo.RedirectStandardOutput = true;
|
|
||||||
p.StartInfo.FileName = _probePath;
|
|
||||||
p.StartInfo.Arguments = $"-v quiet -print_format xml -show_streams -show_format \"{media}\"";
|
|
||||||
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
|
||||||
p.Start();
|
|
||||||
|
|
||||||
result = p.StandardOutput.ReadToEnd();
|
using (var p = new Process())
|
||||||
p.WaitForExit(1000);
|
{
|
||||||
|
p.StartInfo.UseShellExecute = false;
|
||||||
|
p.StartInfo.CreateNoWindow = true;
|
||||||
|
p.StartInfo.RedirectStandardOutput = true;
|
||||||
|
p.StartInfo.FileName = _probePath;
|
||||||
|
p.StartInfo.Arguments = $"-v quiet -print_format xml -show_streams -show_format \"{media}\"";
|
||||||
|
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||||
|
p.Start();
|
||||||
|
|
||||||
|
result = p.StandardOutput.ReadToEnd();
|
||||||
|
p.WaitForExit(1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(result))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ParseResult(result);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
if (string.IsNullOrWhiteSpace(result))
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
ParseResult(result);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ParseResult(string result)
|
private void ParseResult(string result)
|
||||||
@@ -71,28 +78,28 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
|
|||||||
|
|
||||||
public bool CanDecode()
|
public bool CanDecode()
|
||||||
{
|
{
|
||||||
var info = _infoNavigator.SelectSingleNode("/ffprobe/format[@probe_score>25]");
|
var info = _infoNavigator?.SelectSingleNode("/ffprobe/format[@probe_score>25]");
|
||||||
|
|
||||||
return info != null;
|
return info != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatName()
|
public string GetFormatName()
|
||||||
{
|
{
|
||||||
var format = _infoNavigator.SelectSingleNode("/ffprobe/format/@format_name")?.Value;
|
var format = _infoNavigator?.SelectSingleNode("/ffprobe/format/@format_name")?.Value;
|
||||||
|
|
||||||
return format ?? string.Empty;
|
return format ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetFormatLongName()
|
public string GetFormatLongName()
|
||||||
{
|
{
|
||||||
var format = _infoNavigator.SelectSingleNode("/ffprobe/format/@format_long_name")?.Value;
|
var format = _infoNavigator?.SelectSingleNode("/ffprobe/format/@format_long_name")?.Value;
|
||||||
|
|
||||||
return format ?? string.Empty;
|
return format ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasAudio()
|
public bool HasAudio()
|
||||||
{
|
{
|
||||||
var duration = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='audio'][1]/@duration")
|
var duration = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='audio'][1]/@duration")
|
||||||
?.Value;
|
?.Value;
|
||||||
|
|
||||||
if (duration == null)
|
if (duration == null)
|
||||||
@@ -104,7 +111,7 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
|
|||||||
|
|
||||||
public bool HasVideo()
|
public bool HasVideo()
|
||||||
{
|
{
|
||||||
var fps = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@avg_frame_rate")
|
var fps = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@avg_frame_rate")
|
||||||
?.Value;
|
?.Value;
|
||||||
|
|
||||||
if (fps == null)
|
if (fps == null)
|
||||||
@@ -118,9 +125,9 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
|
|||||||
if (!HasVideo())
|
if (!HasVideo())
|
||||||
return Size.Empty;
|
return Size.Empty;
|
||||||
|
|
||||||
var width = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_width")
|
var width = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_width")
|
||||||
?.Value;
|
?.Value;
|
||||||
var height = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_height")
|
var height = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_height")
|
||||||
?.Value;
|
?.Value;
|
||||||
|
|
||||||
if (width == null || height == null)
|
if (width == null || height == null)
|
||||||
|
Reference in New Issue
Block a user