GetInfo("ffmpeg"," -i "+sourcename);
static void GetInfo (string exe,string arg)
{
Process p = new Process ();
try
{
p.StartInfo.FileName = exe;
p.StartInfo.Arguments = arg;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true ;
//启动进程
p.Start();
//等待进程结束
p.WaitForExit();
string Errorstr = p.StandardError.ReadToEnd();
string ss1 = "bitrate:";
string ss2 = "kb/s";
string kbps = Errorstr.Remove(0,Errorstr.IndexOf(ss1)+ss1.Length);
string kbpsstr = kbps.Substring(0,kbps.IndexOf(ss2));
bitratestr = kbpsstr.Trim();
Console.WriteLine("码率:"+bitratestr);
p.Close();
}
catch(Exception ex) {
Console.WriteLine (ex.Message);
}
finally {
}
}
时间: 2024-10-11 21:04:21