我通过从我的c#代码中启动一个ffmpeg进程来提取单个视频帧。默认行为是将这些图像写入磁盘。但是,为了加快处理速度,我希望重定向ffmpeg标准输出以接收流,并在程序中进一步处理它。
我使用的参数与此类似:
-i \"" + Filename + "\" -vf \"scale=640:-1\" -an -vframes 100 -r 1 -f image2 -这会将字节流重定向到标准输出,我可以使用process.StartInfo.RedirectStandardOutput = true将其重定向到我的程序。
这可能适用于电影流,因为我只有一个单独的输出,但上面的调用将产生10个单独的图像(当写入硬盘时),我如何从标准输出中解析字节流并将其分割为单个文件?
发布于 2012-05-10 04:51:26
我找到了一个似乎有效的解决方案,但奇怪的是ffmpeg documentation中没有提到:使用image2pipe作为输出格式。
因此,对于上面的示例,它将是:
-i \"" + Filename + "\" -vf \"scale=640:-1\" -an -vframes 100 -r 1 -f image2pipe -这会将字节流重定向到stdout,并允许捕获和解析图像
发布于 2012-07-31 21:09:41
感谢你的回答@leepfrog,这基本上是一样的:
StringBuilder str = new StringBuilder();
//Input file path
str.Append(string.Format(" -i {0}", myinputFile));
//Set the frame rate
str.Append(string.Format(" -r {0}", myframeRate);
//Indicate the output format
str.Append(" -f image2pipe");
//Connect the output to the standard output
str.Append(" pipe:1");
return str.ToString();https://stackoverflow.com/questions/10505659
复制相似问题