Beispiel #1
0
        public static void GetSizeAsync(string file, Action <Size> callback)
        {
            FFProbeProcess ffprobe = CreateFFProbeProcess(true);

            ffprobe.StartInfo.FileName  = "ffprobe.exe";
            ffprobe.StartInfo.Arguments = $"-v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 \"{file}\"";
            ffprobe.callback            = callback;
            ffprobe.input   = file;
            ffprobe.Exited += FFProbeExited;

            ffprobe.Start();
        }
Beispiel #2
0
        public static Size GetSizeWait(string filepath)
        {
            FFProbeProcess process = CreateFFProbeProcess(false);

            process.StartInfo.FileName  = "ffprobe.exe";
            process.StartInfo.Arguments = $"-v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 \"{filepath}\"";
            process.input = filepath;

            process.Start();

            var nums = process.StandardOutput.ReadLine().Split(new char[] { 'x' }, StringSplitOptions.RemoveEmptyEntries);

            process.StandardOutput.ReadToEnd();     //Fully read both of these buffers to prevent a hand on WaitForExit().
            process.StandardError.ReadToEnd();

            process.WaitForExit();

            process.Close();
            process.Dispose();

            return(new Size(int.Parse(nums[0]), int.Parse(nums[1])));
        }