1

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

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 文档中得到了这个字符串。任何人都可以帮助我吗?

4

0 回答 0