1

我正在尝试从视频文件中获取缩略图并且我的代码成功运行但缩略图没有保存这里是我的代码..

 protected void Convert(string fileIn, string fileOut, string thumbOut)
    {
        try
        {
            System.Diagnostics.Process ffmpeg;

            string video;
            string thumb;

            video = Server.MapPath("~/Content/UploadVedio/YouTube.FLV");
            thumb = Server.MapPath("~/Content/UploadImage/frame.jpg");

            ffmpeg = new System.Diagnostics.Process();

            ffmpeg.StartInfo.Arguments = " -i " + video + " -ss 00:00:07 -vframes 1 -f image2 -vcodec mjpeg " + thumb;
            ffmpeg.StartInfo.FileName = Server.MapPath("~/Content/EXE/ffmpeg.exe");
            ffmpeg.Start();
            ffmpeg.WaitForExit();
            ffmpeg.Close();
        }
        catch (Exception ex)
        {
            Response.Write("Error: " + ex.Message);
        }
    }
4

2 回答 2

0

您的代码在 IIS 中运行,请确保您有权写入正确的文件夹

于 2012-09-22T12:21:58.053 回答
0

要检查的事情:

  1. 目录是否包含空格?如果是这样,请添加:

    视频 = "\"" + 视频 + "\"";拇指 = "\"" + 拇指 + "\"";

  2. ffmpeg.exe 路径是否正确?如果要为 ffmpeg 设置环境变量,请转到此处,这样您就不需要找到运行 ffmpeg 的 ffmpeg.exe 路径。

  3. 即你的论点:-ss 00:00:07。视频长度是否超过 7 秒?

  4. 将 ffmpeg.exe 复制到驱动器 C(如果您没有为 ffmpeg 设置路径)并尝试直接在 cmd 下运行,并在此处发布如果发生任何错误,输出是什么?IE:

    c:\ffmpeg.exe -i "c:\video.mp4" -ss 00:00:07 -vframes 1 -f image2 -vcodec mjpeg "c:\result.jpg"

于 2016-07-19T02:33:17.443 回答