WinForm to WebForm?

1tok4

New Member
This is a question from beginner.
\[code\]using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using AForge.Video;using AForge.Video.VFW;using AForge.Video.DirectShow;namespace aforge{ public partial class Form1 : Form { //AVIWriter writer = new AVIWriter("DIB "); //no compression //AVIWriter writer = new AVIWriter("WMV3"); //with compression AVIWriter writer = new AVIWriter("MSVC"); //with compression // statistics length private const int statLength = 15; // current statistics index private int statIndex = 0; // ready statistics values private int statReady = 0; // statistics array private int[] statCount = new int[statLength]; public bool isrecording = false; public Form1() { string source = "http://*****.*****.com/jpegstream.cgi"; JPEGStream mjpegSource = new JPEGStream(source); mjpegSource.Login = "login"; mjpegSource.Password = "password"; mjpegSource.Start(); // open it OpenVideoSource(mjpegSource); } private void OpenVideoSource(IVideoSource source) { // stop current video source videoSourcePlayer.SignalToStop(); videoSourcePlayer.WaitForStop(); // start new video source videoSourcePlayer.VideoSource = source; videoSourcePlayer.Start(); this.Cursor = Cursors.Default; } private void Form1_Load(object sender, EventArgs e) { } private void videoSourcePlayer_NewFrame(object sender, ref Bitmap image) { DateTime now = DateTime.Now; Graphics g = Graphics.FromImage(image); SolidBrush brush = new SolidBrush(Color.Red); Pen pen = new Pen(brush); g.DrawString(now.ToString(), this.Font, brush, new PointF(5, 5)); brush.Dispose(); g.Dispose(); if (isrecording) { writer.AddFrame(image); } } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (videoSourcePlayer.VideoSource != null) { videoSourcePlayer.SignalToStop(); videoSourcePlayer.WaitForStop(); } } private void BtnStop_Click(object sender, EventArgs e) { isrecording = false; writer.Close(); } private void BtnStart_Click(object sender, EventArgs e) { writer.Open("c:\\test.avi", 640, 480); //launch recording isrecording = true; TxtTimeStart.Text = DateTime.Now.ToString(); } }}\[/code\]first off all, i got this code from internet and i want to implement it in web form. but i couldn't understand completely the code.
what i dont understand is how the AVIWriter get the frame from JPEGStream source and create an AVI video from it as i cant see the connection of that two.
when i test the code/run the code, the output video create an AVI file with double speed when played, so how can i get the actual speed or frame rate per second?.
I really appreciate it if someone can explain and guide me from my confusion.

Source code can be downloaded from here:
http://www.aforgenet.com/forum/download/file.php?id=179New learner, please guide me...
 
Back
Top