我看過各種類似
謝謝
但是當我看png時全是黑色的。當我保存網路攝像頭框架時,保存程序是正確的。你能告訴我我對你的代碼的改編有什么問題嗎?
謝謝
uj5u.com熱心網友回復:
它可能不是專業的解決方案,也不是實時的,但它適用于像您這樣的簡單場景。它是使用 Net Framework 4.7.2 構建的控制臺應用程式。我Aforge.Video.FFMPEG使用它的源代碼重建了程式集,以便它可以與 Net Framework 4.0 一起使用。
using AForge.Video.FFMPEG;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
class Program
{
static VideoFileWriter VideoFileWriter;
static Stopwatch stopwatch = new Stopwatch();
static void Main(string[] args)
{
VideoFileWriter = new VideoFileWriter();
Size screenSize = Screen.PrimaryScreen.Bounds.Size;
VideoFileWriter.Open("test.mp4", screenSize.Width, screenSize.Height, 30, VideoCodec.MPEG4, 19200000);
Bitmap bitmap = new Bitmap(screenSize.Width, screenSize.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bitmap);
stopwatch.Start();
while (stopwatch.Elapsed < TimeSpan.FromSeconds(10)) // Record for ten seconds.
{
g.CopyFromScreen(0, 0, 0, 0, screenSize, CopyPixelOperation.SourceCopy);
VideoFileWriter.WriteVideoFrame(bitmap, stopwatch.Elapsed);
Thread.Sleep(29);
}
VideoFileWriter.Close();
g.Dispose();
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/408101.html
標籤:
上一篇:當Viewmodel未呼叫ErrorsChanged事件時,系結引擎是否還會呼叫INotifyDataErrorInfoGetErrors()?
下一篇:無法在表格中顯示資料
