C# 保存快照
我已经把一切都做好了。除了一个,一切都好。我无法保存拍摄的快照。如果我跟着调试,一切都会好的。。怎么了C# 保存快照,c#,ffmpeg,snapshot,C#,Ffmpeg,Snapshot,我已经把一切都做好了。除了一个,一切都好。我无法保存拍摄的快照。如果我跟着调试,一切都会好的。。怎么了 public class FFMPEG { Process ffmpeg; public void exec(string input, string parametri, string output) { ffmpeg = new Process(); ffmpeg.StartInfo.Arguments = " -i " + in
public class FFMPEG
{
Process ffmpeg;
public void exec(string input, string parametri, string output)
{
ffmpeg = new Process();
ffmpeg.StartInfo.Arguments = " -i " + input + (parametri != null ? " " + parametri : "") + " " + output;
ffmpeg.StartInfo.FileName = HttpContext.Current.Server.MapPath("~/ffmpeg.exe");
ffmpeg.StartInfo.UseShellExecute = false;
ffmpeg.StartInfo.RedirectStandardOutput = true;
ffmpeg.StartInfo.RedirectStandardError = true;
ffmpeg.StartInfo.CreateNoWindow = true;
ffmpeg.Start();
ffmpeg.WaitForExit();
ffmpeg.Close();
}
public void GetThumbnail(string video, string jpg, string velicina)
{
if (velicina == null) velicina = "640x480";
exec(video, "-ss 00:00:06 " + velicina, jpg);
}
}
FFMPEG f = new FFMPEG();
f.GetThumbnail(Server.MapPath("~/Uploads/" + unique), Server.MapPath("~/Thumbnails/" + unique.Remove(unique.IndexOf(".")) + ".jpg"), "1200x223");
我假设您正在提取640x480个缩略图,velicina是用于指定分辨率的参数,根据您发布的部分代码判断。在这种情况下,您有一个ffmpeg语法错误,您可以将GetThumbnail函数更改为以下内容以供尝试:
public void GetThumbnail(string video, string jpg, string velicina)
{
if (velicina == null) velicina = "640x480";
exec(video, "-ss 00:00:06 -s" + velicina, jpg);
}
特别是,-s告诉ffmpeg输出的分辨率。试试看是否行得通