在线转化视频问题 请大家帮忙看下错在什么地方,好象ffmpeg.exe 就没起作用.

fox1025701 2009-04-02 10:24:47
public void ConvertVideo(string str)
{
Process p = new Process();//建立外部调用线程
p.StartInfo.FileName = @"E:\2008Erp\BBS\FLV\ffmpeg.exe";//要调用外部程序的绝对路径
p.StartInfo.Arguments = str;//参数(这里就是FFMPEG的参数了)
p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序启动线程(一定为FALSE,详细的请看MSDN)
p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中(这个一定要注意,FFMPEG的所有输出信息,都为错误输出流,用StandardOutput是捕获不到任何消息的...
p.StartInfo.CreateNoWindow = false;//不创建进程窗口
p.Start();//启动线程
p.WaitForExit();//等待完成
p.StandardError.ReadToEnd();//开始同步读取
p.Close();//关闭进程
p.Dispose();//释放资源
}
protected void Button1_Click(object sender, EventArgs e)
{
string Mapname = DateTime.Now.ToString().Replace(" ", "").Replace("-", "").Replace(":", "");
string str1 = FileUpload1.PostedFile.FileName.ToString();
string name = System.IO.Path.GetExtension(str1);
FileUpload1.PostedFile.SaveAs(Server.MapPath("FLV/vidio/" + Mapname + "" + name + ""));
string str2 = System.Web.HttpContext.Current.Server.MapPath("Flv/vidio/");
ConvertVideo("-i " + str1 + " -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 " + str2 + "\\" + Mapname + ".flv");
Response.Write(" <script>alert('转换成功!'); </script>");
}


E:\2008Erp 这是我项目的存放地方
...全文
124 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fox1025701 2009-04-02
  • 打赏
  • 举报
回复
高手都被这么低碉啊...会被埋没的
fox1025701 2009-04-02
  • 打赏
  • 举报
回复
ffmpeg.exe 任务管理器里这个进程没有,请问是不是我的程序有错误
xuyiazl 2009-04-02
  • 打赏
  • 举报
回复

class VideoProcess
{
public delegate void ProgressBar(int count, int time, int timeCount);
public event ProgressBar progressBar;
string propertytime = "";

private string _Command;
private string _FileName;
public string Command
{
get { return _Command; }
set{_Command = value;}
}
public string FileName
{
get { return _FileName; }
set { _FileName = value; }
}
public VideoProcess(string setCommand,ConvertType.Menu type)
{
this.Command = setCommand;
switch (type) {
case ConvertType.Menu.ffmepg:
this.FileName = System.IO.Path.GetFullPath("system/ffmpeg.exe");
break;
case ConvertType.Menu.ffmepgcut:
this.FileName = System.IO.Path.GetFullPath("system/ffmpeg_cut.exe");
break;
case ConvertType.Menu.mp4box:
this.FileName = System.IO.Path.GetFullPath("system/MP4Box.exe");
break;
case ConvertType.Menu.mencoder:
this.FileName = System.IO.Path.GetFullPath("system/mencoder.exe");
break;
}
}
public void Progress()
{
try
{
Process p = new Process();
p.StartInfo.FileName = this.FileName;
p.StartInfo.Arguments = this.Command;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
p.Start();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
}
catch
{

}
}
void p_ErrorDataReceived(object sendProcess, DataReceivedEventArgs output)
{
if (!String.IsNullOrEmpty(output.Data))
{
Regex _itemexs = new Regex(@"Duration: (?<Time>(\d+):(\d+):(\d+).(\d+)),");

MatchCollection _matches = _itemexs.Matches(output.Data);
foreach (Match item in _matches)
{
propertytime = item.Groups["Time"].Value;
}

Regex _itemex = new Regex(@"frame=(\s*)(\d+) fps= (\d+) q=((\.|\d)+) size=(\s*)(?<size>(\d+))kB time=(\s*)(?<times>(\d|\.)+) bitrate=(\s*)((\d|\.)+)kbits/s");

MatchCollection _itemmatches = _itemex.Matches(output.Data);
foreach (Match itemmatch in _itemmatches)
{
string propertyname = itemmatch.Groups["size"].Value;
string propertytimes = itemmatch.Groups["times"].Value;
int timecount = DateTime.Parse(propertytime).Hour * 3600 + DateTime.Parse(propertytime).Minute * 60 + DateTime.Parse(propertytime).Second;
int times = int.Parse(Math.Ceiling(double.Parse(propertytimes)).ToString());
progressBar(int.Parse(propertyname), times, timecount);
}

}
}
}

xuyiazl 2009-04-02
  • 打赏
  • 举报
回复
创建进程窗口看是否启用

Server.MapPath获取ffmpeg.exe地址
fox1025701 2009-04-02
  • 打赏
  • 举报
回复
自己给自己定起来,怎么就没人来呢
fox1025701 2009-04-02
  • 打赏
  • 举报
回复
自己顶一下..
fox1025701 2009-04-02
  • 打赏
  • 举报
回复
来几个行家啊...
fox1025701 2009-04-02
  • 打赏
  • 举报
回复
...自己继续顶

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧