LoginSignup
0
0

cscの作法 その397

Posted at

概要

cscの作法、調べてみた。
練習問題、やってみた。

練習問題

aforgeでスクリーンをキャプチャしてaviファイルを作成せよ。

サンプルコード



using System;
using System.Drawing;
using System.Windows.Forms;
using AForge.Video;
using AForge.Video.VFW;

class Program {
	[STAThread]
	static void Main(string[] args) {
		System.Threading.Thread.Sleep(1000);
		Console.WriteLine("ok0");
		AVIWriter writer = new AVIWriter("DIB ");
		writer.FrameRate = 10;
		writer.Open("scs0.avi", Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
		ScreenCaptureStream streamVideo = new ScreenCaptureStream(Screen.PrimaryScreen.WorkingArea);
		int i = 0;
		streamVideo.NewFrame += new NewFrameEventHandler((sender, eventArgs) => {
			Console.WriteLine(i);
			writer.AddFrame(eventArgs.Frame);
			i++;
			if (i > 24)
			{
				Console.WriteLine("stop");
				streamVideo.Stop();
				writer.Close();
			}
		});
		streamVideo.Start();
		Console.WriteLine("ok2");
	}
}


以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0