public static async Task <VidExtraData> GetVidExtraInfo(string inputFile) { string ffprobeOutput = await GetVideoInfo.GetFfprobeInfoAsync(inputFile, GetVideoInfo.FfprobeMode.ShowBoth); VidExtraData data = new VidExtraData(ffprobeOutput); return(data); }
public static async Task <Fraction> GetFramerate(string inputFile, bool preferFfmpeg = false) { Logger.Log($"GetFramerate(inputFile = '{inputFile}', preferFfmpeg = {preferFfmpeg})", true, false, "ffmpeg"); Fraction ffprobeFps = new Fraction(0, 1); Fraction ffmpegFps = new Fraction(0, 1); try { string ffprobeOutput = await GetVideoInfo.GetFfprobeInfoAsync(inputFile, GetVideoInfo.FfprobeMode.ShowStreams, "r_frame_rate"); string fpsStr = ffprobeOutput.SplitIntoLines().First(); string[] numbers = fpsStr.Split('/'); Logger.Log($"Fractional FPS from ffprobe: {numbers[0]}/{numbers[1]} = {((float)numbers[0].GetInt() / numbers[1].GetInt())}", true, false, "ffmpeg"); ffprobeFps = new Fraction(numbers[0].GetInt(), numbers[1].GetInt()); } catch (Exception ffprobeEx) { Logger.Log("GetFramerate ffprobe Error: " + ffprobeEx.Message, true, false); } try { string ffmpegOutput = await GetVideoInfo.GetFfmpegInfoAsync(inputFile); string[] entries = ffmpegOutput.Split(','); foreach (string entry in entries) { if (entry.Contains(" fps") && !entry.Contains("Input ")) // Avoid reading FPS from the filename, in case filename contains "fps" { string num = entry.Replace(" fps", "").Trim().Replace(",", "."); Logger.Log($"Float FPS from ffmpeg: {num.GetFloat()}", true, false, "ffmpeg"); ffmpegFps = new Fraction(num.GetFloat()); } } } catch (Exception ffmpegEx) { Logger.Log("GetFramerate ffmpeg Error: " + ffmpegEx.Message, true, false); } if (preferFfmpeg) { if (ffmpegFps.GetFloat() > 0) { return(ffmpegFps); } else { return(ffprobeFps); } } else { if (ffprobeFps.GetFloat() > 0) { return(ffprobeFps); } else { return(ffmpegFps); } } }
private void button1_Click(object sender, RoutedEventArgs e) { GetVideoInfo getVideoInfo = new GetVideoInfo(); getVideoInfo.GetStream(); }