示例#1
0
        private static void FFProbeExited(object sender, EventArgs e)
        {
            FFProbeProcess p = (FFProbeProcess)sender;

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

            if (nums.Length == 2)
            {
                p.callback.Invoke(new Size(int.Parse(nums[0]), int.Parse(nums[1])));
            }
            else
            {
                p.callback.Invoke(new Size(0, 0));
            }

            p.Close();
            p.Dispose();
        }
示例#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])));
        }