我正在嘗試創建.wmv視頻的縮略圖。我曾嘗試以下代碼:如何使用ffmpeg.exe創建縮略圖
Guid id = Guid.NewGuid();
string thumbpath, thumbname, videopath;
string thumbargs, inputfile;
thumbpath = "C:\\Users\\Tom\\Desktop\\picture gallery\\";
thumbname = thumbpath + id.ToString() + ".jpg";
videopath = "C:\\Users\\Tom\\Desktop\\video gallery\\";
inputfile = Videopath + id.ToString() + ".wmv";
thumbargs = "-i " + inputfile + " -vframes 1 -ss 00:00:07 -s 150x150 -f image2 " + thumbname;
Process thumbproc = new Process();
thumbproc = new Process();
thumbproc.StartInfo.FileName = "C:\\Users\\Tom\\Desktop\\ffmpeg\\ffmpeg.exe";
thumbproc.StartInfo.UseShellExecute = false;
thumbproc.StartInfo.CreateNoWindow = false;
thumbproc.StartInfo.RedirectStandardOutput = false;
try
{
thumbproc.Start();
if (thumbproc != null)
{
thumbproc.Close();
}
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Visible = true;
}
我正在訪問存儲在「視頻庫」文件夾中的視頻。我的解決方案的問題是,當我運行該解決方案時,它顯示錯誤「找不到合適的輸出格式ffmpeg'gallery \ 69b77a48-1b3c-4ce7-8c5a-fba10af5d9b1.jpg'」。
但是,如果我刪除縮略圖(圖片庫或視頻圖庫)的路徑中的空間,那麼它工作正常。
請告訴我有沒有我的「thumbargs」或我的代碼中缺少的任何問題。
我加了後者。 thumbproc.StartInfo.Arguments = thumbargs;那麼我也面臨同樣的問題。 – prasad