我试图将大量桌面捕获的图像发送到编码器(FFmpeg)stdin.
以下代码示例有效.
该CaptureScreen()功能可在5-10毫秒内提供图像.
如果我将图像保存在MemoryStream中,几乎不需要时间.
但我只能每45毫秒将1张图像保存到proc.StandardInput.BaseStream.
public void Start(string bitrate, string buffer, string fps, string rtmp, string resolution, string preset)
{
proc.StartInfo.FileName = myPath + "\\ffmpeg.exe";
proc.StartInfo.Arguments = "-f image2pipe -i pipe:.bmp -vcodec libx264 -preset " + preset + " -maxrate " + bitrate + "k -bufsize " +
buffer + "k -bt 10 -r " + fps + " -an -y test.avi"; //+ rtmp;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
Stopwatch st = new …Run Code Online (Sandbox Code Playgroud)