मैं कई डेस्कटॉप कैप्चर की गई छवियों को एन्कोडर्स (एफएफएमपीईजी) stdin में भेजने की कोशिश कर रहा हूं।प्रक्रिया में छवि लिखने का तेज़ तरीका। मानक इनपुट। बेसस्ट्रीम
निम्नलिखित कोड उदाहरण काम करता है।
CaptureScreen()
फ़ंक्शन 5-10 एमएस में एक छवि प्रदान करता है।
यदि मैं मेमोरीस्ट्रीम में छवि को सहेजता हूं तो इसमें लगभग कोई समय नहीं लगता है।
लेकिन मैं केवल proc.StandardInput.BaseStream को 1 छवि हर 45 एमएस बचा सकता है।
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());
}
सवाल यह है:
मैं बचत की प्रक्रिया तेजी से कर सकता हूँ?
मैं इस तरह से
क्या आपने 'ImageFormat.png' का उपयोग करने का प्रयास किया है, इसलिए पढ़ने/लिखे जाने वाले डेटा की वास्तविक मात्रा कम हो गई है? – PhonicUK
मैंने कोशिश की। इसकी धीमी गति से ... 130 एमएस – Hasibii