在asp.net中使用FFMPEG将视频转换为flv无法正常工作?

时间:2012-11-05 15:49:42

标签: asp.net-mvc

这是我在上传到服务器时转换视频的代码

private bool ReturnVideo(string fileName)     {         string html = string.Empty;         //如果文件已存在则重命名

    int j = 0;
    string AppPath;
    string inputPath;
    string outputPath;
    string imgpath;
    AppPath = Request.PhysicalApplicationPath;
    //Get the application path 
    inputPath = AppPath + "OriginalVideo";
    //Path of the original file 
    outputPath = AppPath + "ConvertVideo";
    //Path of the converted file 
    imgpath = AppPath + "Thumbs";
    //Path of the preview file 
    string filepath = Server.MapPath("~/OriginalVideo/" + fileName);
    while (File.Exists(filepath))
    {
        j = j + 1;
        int dotPos = fileName.LastIndexOf(".");
        string namewithoutext = fileName.Substring(0, dotPos);
        string ext = fileName.Substring(dotPos + 1);
        fileName = namewithoutext + j + "." + ext;
        filepath = Server.MapPath("~/OriginalVideo/" + fileName);
    }
    try
    {
        this.fileuploadImageVideo.SaveAs(filepath);
    }
    catch
    {
        return false;
    }
    string outPutFile;
    outPutFile = "~/OriginalVideo/" + fileName;
    int i = this.fileuploadImageVideo.PostedFile.ContentLength;
    System.IO.FileInfo a = new System.IO.FileInfo(Server.MapPath(outPutFile));
    while (a.Exists == false)
    {

    }
    long b = a.Length;
    while (i != b)
    {

    }
    string convertString = string.Format(" -i {0} -ar 22050 -ab 128 -acodec mp3 -r 25 -f flv -b 800 -s 640x480 {1}", inputPath + "\\" + fileName, outputPath + "\\" + fileName.Remove(fileName.IndexOf("."))+ ".flv");
    ConvertNow(convertString);
    string imgargs = " -i \"" + outputPath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".flv" + "\" -f image2 -ss 1 -vframes 1 -s 280x200 -an \"" + imgpath + "\\" + fileName.Remove(fileName.IndexOf(".")) + ".jpg" + "\"";
    ConvertNow(imgargs);


    return true;
}

我猜这是convertString的错误,但是我从ffmpeg文档中得到了这个字符串。任何人都可以帮助我吗?

0 个答案:

没有答案