首页 > 编程 > .NET > 正文

在ASP.Net中实现flv视频转换的代码

2024-07-10 12:39:59
字体:
来源:转载
供稿:网友
实际上是利用.Net中的Process对象来实现的。
   string str=@"d:/test.avi  d:/test_allen.flv";
   RunFFMpeg(str);



   //运行FFMpeg的视频解码,
   public void RunFFMpeg(string strCmd)
   {
       //创建并启动一个新进程
       Process p = new Process();
       //设置进程启动信息属性StartInfo,这是ProcessStartInfo类,包括了一些属性和方法:
       p.StartInfo.FileName = "ffmpeg.exe";           //程序名
       p.StartInfo.Arguments = " -i " + strCmd;    //执行参数
       p.Start();
   }

   //运行Cmd.exe执行Dos 命令,并返回执行结果 
   public string RunCmd(string command)
   {
       //创建并启动一个对进程
       Process p = new Process();

       //Process类有一个StartInfo属性,这是ProcessStartInfo类,包括了一些属性和方法,例如:
       p.StartInfo.FileName = "cmd.exe";           //程序名
       p.StartInfo.Arguments = " /c " + command;    //执行参数
       p.StartInfo.UseShellExecute = false;        //关闭Shell的使用
       p.StartInfo.RedirectStandardInput = true;   //重定向标准输入
       p.StartInfo.RedirectStandardOutput = true;  //重定向标准输出
       p.StartInfo.RedirectStandardError = true;   //重定向错误输出
       p.StartInfo.CreateNoWindow = true;          //设置不显示窗口

       p.Start(); 
       //p.StandardInput.WriteLine(command);       //也可以用這種方式輸入要執行的命令
       //p.StandardInput.WriteLine("exit");        //不過要記得加上Exit要不然下一行程式執行的時候會當機
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表