• 大小: 6.52MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-29
  • 语言: 其他
  • 标签: AForge  Demo  

资源简介

该Demo实现了基本的AForge录制视频等功能。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Timers;

//using AForge
using AForge;
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Video.FFMPEG;
using AForge.Controls;

namespace video_record
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        //关闭窗口响应函数
        private void button2_Click(object sender EventArgs e)
        {
            if (this.writer.IsOpen)
            {
                MessageBox.Show(“视频流还没有写完,请点击结束录制。“ “错误“ MessageBoxButtons.OK MessageBoxIcon.Error);
                return;
            }
            this.videoSource.SignalToStop();
            this.videoSource.WaitForStop();
            this.videoSourcePlayer.SignalToStop();
            this.videoSourcePlayer.WaitForStop();
            this.Hide();
            this.Close();
            this.Dispose();
        }

        private FilterInfoCollection videoDevices;  //摄像头设备
        private VideoCaptureDevice videoSource;     //视频的来源选择
        private VideoSourcePlayer videoSourcePlayer;    //AForge控制控件
        private VideoFileWriter writer;     //写入到视频
        private bool is_record_video = false;   //是否开始录像
        System.Timers.Timer timer_count;
        int tick_num = 0;

        //窗体初始化函数
        private void Form1_Load(object sender EventArgs e)
        {
            this.label5.Visible = false;

            this.videoSourcePlayer = new AForge.Controls.VideoSourcePlayer();
            this.videoSource = new VideoCaptureDevice();
            this.writer = new VideoFileWriter();

            //设置视频编码格式
            this.comboBox_videoecode.Items.Add(“Raw“);
            this.comboBox_videoecode.Items.Add(“MPEG2“);
            this.comboBox_videoecode.Items.Add(“FLV1“);
            this.comboBox_videoecode.Items.Add(“H263p“);
            this.comboBox_videoecode.Items.Add(“MSMPEG4v3“);
            this.comboBox_videoecode.Items.Add(“MSMPEG4v2“);
            this.comboBox_videoecode.Items.Add(“WMV2“);
            this.comboBox_videoecode.Items.Add(“WMV1“);
            this.comboBox_videoecode.Items.Add(“MPEG4“);
            this.comboBox_videoecode.SelectedIndex = 1;

            //设置视频来源
            try
            {
                // 枚举所有视频输入设备
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

                if (videoDevices.Count == 0)
                    throw new ApplicationException();   //没有找到摄像头设备

                foreach (FilterInfo device in videoDevices)
                {
                    this.comboBox_camera.Items.Add(device.Name);
                }
                //this.comboBox_camera.SelectedIndex = 0;   //注释掉,选择摄像头来源的时候才会才会触发显示摄像头信息
            }
   

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      44544  2013-07-15 23:04  video_record\video_record\AForge\AForge.Controls.dll

     文件      66108  2013-07-15 23:04  video_record\video_record\AForge\AForge.Controls.xml

     文件      20480  2013-07-15 23:07  video_record\video_record\AForge\AForge.DebuggerVisualizers (2010).dll

     文件      17920  2013-07-15 23:04  video_record\video_record\AForge\AForge.dll

     文件      15872  2013-07-15 23:04  video_record\video_record\AForge\AForge.Fuzzy.dll

     文件      80837  2013-07-15 23:04  video_record\video_record\AForge\AForge.Fuzzy.xml

     文件      25600  2013-07-15 23:04  video_record\video_record\AForge\AForge.Genetic.dll

     文件     119443  2013-07-15 23:04  video_record\video_record\AForge\AForge.Genetic.xml

     文件     262656  2013-07-15 23:04  video_record\video_record\AForge\AForge.Imaging.dll

     文件      16384  2013-07-15 23:04  video_record\video_record\AForge\AForge.Imaging.Formats.dll

     文件      28416  2013-07-15 23:04  video_record\video_record\AForge\AForge.Imaging.Formats.xml

     文件       5632  2013-07-15 23:08  video_record\video_record\AForge\AForge.Imaging.IPPrototyper.dll

     文件     944046  2013-07-15 23:04  video_record\video_record\AForge\AForge.Imaging.xml

     文件       8704  2013-07-15 23:04  video_record\video_record\AForge\AForge.MachineLearning.dll

     文件      22480  2013-07-15 23:04  video_record\video_record\AForge\AForge.MachineLearning.xml

     文件      68096  2013-07-15 23:04  video_record\video_record\AForge\AForge.Math.dll

     文件     270650  2013-07-15 23:04  video_record\video_record\AForge\AForge.Math.xml

     文件      21504  2013-07-15 23:04  video_record\video_record\AForge\AForge.Neuro.dll

     文件      83378  2013-07-15 23:04  video_record\video_record\AForge\AForge.Neuro.xml

     文件      23040  2013-07-15 23:04  video_record\video_record\AForge\AForge.Robotics.Lego.dll

     文件      94429  2013-07-15 23:04  video_record\video_record\AForge\AForge.Robotics.Lego.xml

     文件      18432  2013-07-15 23:04  video_record\video_record\AForge\AForge.Robotics.Surveyor.dll

     文件      69963  2013-07-15 23:04  video_record\video_record\AForge\AForge.Robotics.Surveyor.xml

     文件      18432  2013-07-15 23:04  video_record\video_record\AForge\AForge.Robotics.TeRK.dll

     文件      51688  2013-07-15 23:04  video_record\video_record\AForge\AForge.Robotics.TeRK.xml

     文件      61440  2013-07-15 23:04  video_record\video_record\AForge\AForge.Video.DirectShow.dll

     文件     195287  2013-07-15 23:04  video_record\video_record\AForge\AForge.Video.DirectShow.xml

     文件      20992  2013-07-15 23:04  video_record\video_record\AForge\AForge.Video.dll

     文件      61952  2013-07-15 23:07  video_record\video_record\AForge\AForge.Video.FFMPEG.dll

     文件     241743  2013-07-15 23:07  video_record\video_record\AForge\AForge.Video.FFMPEG.xml

............此处省略60个文件信息

评论

共有 条评论