我是初学者。从下面的代码创建视频后,我应该如何以及在何处放置标签消息。
我想在流程完成后显示两条消息,即 label1:视频已成功创建,第二条消息是视频的视频路径。
我只想在过程完成后显示它(创建视频)。
namespace test
{
public partial class liveRecording : System.Web.UI.Page
{
//video codec
AVIWriter writer = new AVIWriter("MSVC");
protected void Page_Load(object sender, EventArgs e)
{
string streamingSource = "http://xxx.sample.com:85/snapshot.cgi";
string login = "login";
string password = "password";
JPEGStream JPEGSource = new JPEGStream(streamingSource);
JPEGSource.Login = login;
JPEGSource.Password = password;
JPEGSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
JPEGSource.Start();
}
public bool IsRecording = false;
int width = 0;
int height = 0;
Queue<Bitmap> frames = new Queue<Bitmap>(); //Queue that store frames to be written by the recorder thread
private void video_NewFrame(object sender, NewFrameEventArgs eventArgs) //event handler for NewFrame
{
//get frame from JPEGStream source
//Bitmap image = eventArgs.Frame;
Bitmap image = (Bitmap)eventArgs.Frame.Clone(); //get a copy of the Bitmap from the source
width = image.Width;
height = image.Height;
if (IsRecording)
{
//enqueue the current frame to be encoded to a video file
frames.Enqueue((Bitmap)image.Clone());
}
if (!IsRecording)
{
IsRecording = true;
Thread th = new Thread(DoRecording);
th.Start();
}
}
private void DoRecording()
{
//writer.FrameRate = 5;
string SavingPath = (Server.MapPath("~\\video\\"));
string VideoName = "ICS_" + String.Format("{0:yyyyMMdd_hhmmss}", DateTime.Now) + ".avi";
writer.Open(SavingPath + VideoName, width, height);
DateTime start = DateTime.Now;
while (DateTime.Now.Subtract(start).Seconds < 30)
{
if (frames.Count > 0)
{
Bitmap bmp = frames.Dequeue();
writer.AddFrame(bmp);//add frames to AVI file
}
}
writer.Close();//close
}
}
}