많은 캡처 된 이미지를 인코더 (FFmpeg) 표준으로 보내려고합니다.Process.StandardInput.BaseStream에 이미지를 빠르게 작성하는 방법
다음 코드 예제가 작동합니다.
CaptureScreen()
기능은 5-10ms의 이미지를 제공합니다.
이미지를 MemoryStream에 저장하면 거의 시간이 걸리지 않습니다.
그러나 나는 4535136 이미지를 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 Stopwatch();
BinaryWriter writer = new BinaryWriter(proc.StandardInput.BaseStream);
System.Drawing.Image img;
st.Reset();
st.Start();
for (int z = 0; z < 100; z++)
{
img = ScrCap.CaptureScreen();
img.Save(writer.BaseStream, System.Drawing.Imaging.ImageFormat.Bmp);
img.Dispose();
}
st.Stop();
System.Windows.Forms.MessageBox.Show(st.ElapsedMilliseconds.ToString());
}
질문 :
내가 구원의 과정을 빠르게 할 수 있습니까?
나는 안정적인 60 FPS에게 여기 병목는 FFmpeg 속도가 느린 그것은을 .avi 압축 같은 속도로 데이터를 읽고 있다는 것입니다 이런 식으로
'ImageFormat.png'을 사용해 보았는가? 그래서 실제로 쓰거나 읽는 데이터 양이 줄어 들었습니까? – PhonicUK
나는 그것을 시험해 보았다. 그것도 더 느린 ... 130 MS – Hasibii