FFmpeg没有转换视频(或者保存它们,我老实说也不知道)并且甚至没有给我任何错误,什么是错的?继承我的代码:
@{
WebSecurity.RequireAuthenticatedUser();
var db = Database.Open("PhotoGallery");
var fileName = "";
var uploader = WebSecurity.CurrentUserId;
var date = DateTime.Now.Date;
var extention = "";
if(IsPost){
var numFiles = Request.Files.Count;
if(numFiles <= 0){
ModelState.AddError("fileUpload", "Please specify at least one photo to upload.");
}
else{
var fileSavePath = "";
var uploadedFile = Request.Files[0];
fileName = Path.GetFileNameWithoutExtension(uploadedFile.FileName).Trim();
extention = Path.GetExtension(uploadedFile.FileName).Trim();
string ndom = Path.GetRandomFileName();
var none = ndom.Remove(ndom.Length - 4);
fileSavePath = Server.MapPath("~/Images/userpics/" +
none + extention);
uploadedFile.SaveAs(fileSavePath);
string AppPath = Request.PhysicalApplicationPath;
string inputPath = AppPath + "~/Images/userpics/" + fileName + extention;
string outputPath = AppPath + "~/Images/userpics/" + fileName + ".flv";
string imgpath = AppPath + "~/Images/userpics/thumbnails/";
string cmd = " -i" + " " + inputPath + " " + outputPath;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = Server.MapPath("~/bin/ffmpeg.exe");
proc.StartInfo.Arguments = cmd;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = false;
proc.Start();
var insertCommand = "INSERT INTO Videos (FileTitle, UploadDate, UserId, ext, Name) Values(@0, @1, @2, @3, @4)";
db.Execute(insertCommand, fileName, date, uploader, extention, none + extention);
Response.Redirect(Href("~/Photo/View", db.GetLastInsertId()));
}
}
}
<h1>Upload Video</h1>
<form method="post" enctype="multipart/form-data">
@Html.ValidationSummary("Unable to upload:")
<fieldset class="no-legend">
<legend>Upload Photo</legend>
@FileUpload.GetHtml(addText: "Add more files", uploadText: "Upload", includeFormTag: false)
<p class="form-actions">
<input type="submit" value="Upload" title="Upload photo" />
</p>
</fieldset>
</form>
<p class="message info">
The maximum file size is 50MB.
</p>
顺便说一下我以为我应该提一下ffmpeg.exe在我的网站bin目录下(只有ffmpeg.exe)