以下部分是对以上类中方法的调用
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 Vedio.BLL;
using Vedio.Models;
using Vedio.DAL;
namespace VedioWeb
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
VediocameraManager vm = new VediocameraManager();
VedionameManager vr = new VedionameManager();
Label lab = null;
cVideo video;
private void Form2_Load(object sender, EventArgs e)
{
List<Vediocamera> li = vm.GetVediocameraListByAll();
for (int i = 0; i < vm.getcount(); i++)
{
lab=new Label();
lab.Name = li[i].CameraID.ToString();
lab.Text = li[i].CameraName;
lab.Location = new Point(40, 40 + (i * 40));
//所有的标签都绑定到同一事件
lab.Click += new System.EventHandler(btn_click);
panel1.Controls.Add(lab);
}
video = new cVideo(pictureBox1.Handle, 0, 0, pictureBox1.Width, pictureBox1.Height);
video.StartVideo();
}
/// <summary>
/// 摄像头列表的单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void btn_click(object sender, EventArgs e)
{
}
/// <summary>
/// pannel加载事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panel2_Paint(object sender, PaintEventArgs e)
{
axRealAudio1.Visible = false;
List<Vediocamera> lm=vm.GetVediocameraListByAll();
tv_info.Nodes.Clear();
TreeNode tvr = null;
foreach (Vediocamera item in lm)
{
tvr = new TreeNode(item.CameraName);
List<string> yy = vr.getmany(item.CameraID);
foreach (string yn in yy)
{
TreeNode tn = new TreeNode(yn);
tvr.Nodes.Add(tn);
}
tv_info.Nodes.Add(tvr);
}
}
/// <summary>
/// 树形菜单的选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tv_info_AfterSelect(object sender, TreeViewEventArgs e)
{
if (tv_info.SelectedNode.Level ==0)
{
MessageBox.Show("此节点不可选择");
return;
}
else
{
axRealAudio1.Visible = true;
string nm = tv_info.SelectedNode.Text;
this.axRealAudio1.SetControls("ImageWindow,controlpanel");
this.axRealAudio1.Source ="C:/Documents and Settings/Administrator/桌面/VedioProgess/VedioWeb/bin/Debug/" + nm + "";
//mencoder -oac faac -faacopts br=64:mpeg=2:object=1 -srate 44100 -vf scale=400:240,harddup -ofps 15 -ovc xvid -xvidencopts bitrate=320 待压缩的文件 -o 输出文件名.mp4
this.axRealAudio1.SetLoop(true);
this.axRealAudio1.SetFullScreen();
this.axRealAudio1.SetWantErrors(true);
this.axRealAudio1.AutoStart = true;
}
}
/// <summary>
/// 开始录像
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_start_Click(object sender, EventArgs e)
{
video.StarKinescope(@"d:\" + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".3GP");
btn_cancel.Enabled = true;
btn_start.Enabled = false;
}
/// <summary>
/// 拍摄照片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_vedio_Click(object sender, EventArgs e)
{
video.Images(@"d:\" + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".JPG");
}
/// <summary>
/// 结束录制
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_cancel_Click(object sender, EventArgs e)
{
video.StopKinescope();
btn_start.Enabled = true;
btn_cancel.Enabled = false;
}
/// <summary>
/// 退出程序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
这个实例运行没错,视频截图也可以实现,但是视频录制有点问题,视频在刚开始录制的时候会有一点点卡,录制的视频内容似乎只是录制了卡的这一段时间,卡的时间也不相同,停止录制的按钮并没有起到作用,对此我很疑惑,请各位大侠帮我看看到底是什么问题。本人不胜感激
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 Vedio.BLL;
using Vedio.Models;
using Vedio.DAL;
namespace VedioWeb
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
VediocameraManager vm = new VediocameraManager();
VedionameManager vr = new VedionameManager();
Label lab = null;
cVideo video;
private void Form2_Load(object sender, EventArgs e)
{
List<Vediocamera> li = vm.GetVediocameraListByAll();
for (int i = 0; i < vm.getcount(); i++)
{
lab=new Label();
lab.Name = li[i].CameraID.ToString();
lab.Text = li[i].CameraName;
lab.Location = new Point(40, 40 + (i * 40));
//所有的标签都绑定到同一事件
lab.Click += new System.EventHandler(btn_click);
panel1.Controls.Add(lab);
}
video = new cVideo(pictureBox1.Handle, 0, 0, pictureBox1.Width, pictureBox1.Height);
video.StartVideo();
}
/// <summary>
/// 摄像头列表的单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void btn_click(object sender, EventArgs e)
{
}
/// <summary>
/// pannel加载事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void panel2_Paint(object sender, PaintEventArgs e)
{
axRealAudio1.Visible = false;
List<Vediocamera> lm=vm.GetVediocameraListByAll();
tv_info.Nodes.Clear();
TreeNode tvr = null;
foreach (Vediocamera item in lm)
{
tvr = new TreeNode(item.CameraName);
List<string> yy = vr.getmany(item.CameraID);
foreach (string yn in yy)
{
TreeNode tn = new TreeNode(yn);
tvr.Nodes.Add(tn);
}
tv_info.Nodes.Add(tvr);
}
}
/// <summary>
/// 树形菜单的选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tv_info_AfterSelect(object sender, TreeViewEventArgs e)
{
if (tv_info.SelectedNode.Level ==0)
{
MessageBox.Show("此节点不可选择");
return;
}
else
{
axRealAudio1.Visible = true;
string nm = tv_info.SelectedNode.Text;
this.axRealAudio1.SetControls("ImageWindow,controlpanel");
this.axRealAudio1.Source ="C:/Documents and Settings/Administrator/桌面/VedioProgess/VedioWeb/bin/Debug/" + nm + "";
//mencoder -oac faac -faacopts br=64:mpeg=2:object=1 -srate 44100 -vf scale=400:240,harddup -ofps 15 -ovc xvid -xvidencopts bitrate=320 待压缩的文件 -o 输出文件名.mp4
this.axRealAudio1.SetLoop(true);
this.axRealAudio1.SetFullScreen();
this.axRealAudio1.SetWantErrors(true);
this.axRealAudio1.AutoStart = true;
}
}
/// <summary>
/// 开始录像
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_start_Click(object sender, EventArgs e)
{
video.StarKinescope(@"d:\" + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".3GP");
btn_cancel.Enabled = true;
btn_start.Enabled = false;
}
/// <summary>
/// 拍摄照片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_vedio_Click(object sender, EventArgs e)
{
video.Images(@"d:\" + DateTime.Today.Month.ToString() + DateTime.Today.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".JPG");
}
/// <summary>
/// 结束录制
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_cancel_Click(object sender, EventArgs e)
{
video.StopKinescope();
btn_start.Enabled = true;
btn_cancel.Enabled = false;
}
/// <summary>
/// 退出程序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
这个实例运行没错,视频截图也可以实现,但是视频录制有点问题,视频在刚开始录制的时候会有一点点卡,录制的视频内容似乎只是录制了卡的这一段时间,卡的时间也不相同,停止录制的按钮并没有起到作用,对此我很疑惑,请各位大侠帮我看看到底是什么问题。本人不胜感激
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货