すべてのストリーミング jpeg を取得して avi を作成するにはどうすればよいですか?
Bitmap img = eventArgs.Frame;
for (int i = 0; i < 1000; i++)
{
//img.SetPixel(i, i, Color.Red);
writer.AddFrame(img);
}
writer.Close();
この例は AForge から入手 しました。動画の最初から最後まで。
writer.AddFrame(img); を実行するにはどうすればよいですか。毎回新しいフレームでビデオ ファイルを作成するには?
編集:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Drawing;
using System.IO;
using AForge.Video;
using AForge.Video.VFW;
using AForge.Video.DirectShow;
namespace VidRec
{
public partial class LiveRecording : System.Web.UI.Page
{
AVIWriter writer = new AVIWriter("MSVC"); //video with compression
protected void Page_Load(object sender, EventArgs e)
{
//camera source
string streamingSource = "http://e888.example.com:81/snapshot.cgi";
// create new AVI file and open it
writer.Open("c:\\video.avi", 640, 480);
//IPcam streaming source to be recorded
JPEGStream JPEGSource = new JPEGStream(streamingSource);
//MJPEGStream JPEGSource = new MJPEGStream(streamingSource);
//login name and password
JPEGSource.Login = "login";
JPEGSource.Password = "password";
//set NewFrame event handler
JPEGSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
//start streaming the image files
JPEGSource.Start();
}
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs) //event handler for NewFrame
{
//get frame
Bitmap image = eventArgs.Frame;
//add the image as a new frame of video file
writer.AddFrame(image);
}
protected void Button1_Click(object sender, EventArgs e)
{
writer.Close();
}
}
}