ffmpeg--服务器处理完后,chrome无法加载mp4

时间:2018-06-26 07:34:12

标签: c# video ffmpeg

我正在使用C#和ffmpeg一起写服务器端来处理一些视频文件。从客户端加载视频文件并将流写入新文件后,我无法使用ffmpeg来提取一些视频文件原始文件的一部分,代码如下

string cmd = "-ss " + string.Format("{0:F}", startTime) + " -t " + string.Format("{0:F}", endTime - startTime) + " -i " + filePath + " -vcodec copy -acodec copy " + filePath + " -y";

它显示错误[mov,mp4,m4a,3gp,3g2,mj2 @ 000002336e7da340]流1,偏移量0x8fab:部分文件;处理输入时发现无效数据

经过调查,我发现我提到的文件路径(服务器端)可能被Windows命令占用(我使用Process处理ffmpeg)

Process myPro = new Process();
        myPro.StartInfo.FileName = WebConfigurationManager.AppSettings["FFMPEGPath"];
        myPro.StartInfo.UseShellExecute = false;
        myPro.StartInfo.RedirectStandardInput = true;
        myPro.StartInfo.RedirectStandardOutput = true;
        myPro.StartInfo.RedirectStandardError = true;
        myPro.StartInfo.CreateNoWindow = true;
        myPro.Start();
        myPro.StandardInput.AutoFlush = true;
        myPro.WaitForExit();
        myPro.Close();
        myPro.Dispose();
        return output;

我决定创建一个新文件来执行提取操作,并且它可以正常工作。

string cmd = "-ss " + string.Format("{0:F}", startTime) + " -t " + string.Format("{0:F}", endTime - startTime) + 
" -i " + filePath + " -vcodec copy -acodec copy " + filePathfull + " -y";

但是当我尝试通过ajax将文件名发回客户端并在html中使用video标签时,它无法加载mp4文件,我想,由ffmpeg生成的mp4文件仍被系统线程占用,您遇到过这种情况吗?如何解决?非常感谢!

0 个答案:

没有答案