public static bool AutoGenerateVideoInfo(IAssFormat format, VideoFileInfo file) { if (new[] { "jpg", "tif", "raw", "png", "dng", "arw", "nef", "cr2", "rw2" }.Contains(file.File.Extension.ToLower().TrimStart('.'))) { file.StartTime = file.File.LastWriteTime; return(true); } ProcessStartInfo startInfo = new ProcessStartInfo() { UseShellExecute = false, CreateNoWindow = true, RedirectStandardError = true, RedirectStandardInput = true, RedirectStandardOutput = true, FileName = "ffprobe", Arguments = $"-v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 \"{file.FilePath}\"" }; Process p = new Process() { StartInfo = startInfo }; p.Start(); p.WaitForExit(); var output = p.StandardOutput.ReadToEnd().Trim(); if (double.TryParse(output, out double length)) { file.Length = TimeSpan.FromSeconds(length); } else { return(false); } var modifiedTime = file.File.LastWriteTime; file.StartTime = modifiedTime - file.Length; return(true); }
private async void HyperlinkButton_Click(object sender, RoutedEventArgs e) { VideoFileInfo file = (sender as FrameworkElement).Tag as VideoFileInfo; (sender as FrameworkElement).IsEnabled = false; try { new Process() { StartInfo = new ProcessStartInfo(file.FilePath) { UseShellExecute = true } }.Start(); } catch (Exception ex) { await ShowMessageAsync("无法打开该文件:" + ex.Message); } await Task.Delay(1000); (sender as FrameworkElement).IsEnabled = true; }