using(Process ffmpeg = new Process())
{
String duration; // soon will hold our video's duration in the form "HH:MM:SS.UU"
String result; // temp variable holding a string representation of our video's duration
StreamReader errorreader; // StringWriter to hold output from ffmpeg
// we want to execute the process without opening a shell
ffmpeg.StartInfo.UseShellExecute = false;
ffmpeg.StartInfo.ErrorDialog = false;
ffmpeg.StartInfo.RedirectStandardError = true;
ffmpeg.StartInfo.FileName = "[directory of ffmpeg.exe]\ffmpeg.exe";
ffmpeg.StartInfo.Arguments = "-i [directory of video file]\video_file";
// start the process
ffmpeg.Start();
// now that the process is started, we can redirect output to the StreamReader we defined
errorreader = ffmpeg.StandardError;
// wait until ffmpeg comes back
ffmpeg.WaitForExit([time_to_wait_in_milliseconds]);
// read the output from ffmpeg, which for some reason is found in Process.StandardError
result = errorreader.ReadToEnd();
// a little convoluded, this string manipulation...
// working from the inside out, it:
// takes a substring of result, starting from the end of the "Duration: " label contained within,
// (execute "ffmpeg.exe -i somevideofile" on the command-line to verify for yourself that it is there)
// and going the full length of the timestamp.
// The resulting substring is of the form "HH:MM:SS.UU"
duration = result.Substring(result.IndexOf("Duration: ") + ("Duration: ").Length, ("00:00:00.00").Length);
}