Video source for video files.

The video source provides access to video files. DirectShow is used to access video files.

Sample usage:

// create video source FileVideoSource videoSource = new FileVideoSource( fileName ); // set NewFrame event handler videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame ); // start the video source videoSource.Start( ); // ... // signal to stop videoSource.SignalToStop( ); // ... // New frame event handler, which is invoked on each new available video frame private void video_NewFrame( object sender, NewFrameEventArgs eventArgs ) { // get new frame Bitmap bitmap = eventArgs.Frame; // process the frame }
Inheritance: IVideoSource
        // Class constructor
        public MainForm( )
        {
            InitializeComponent( );

            // For debugging, instantly open the test file.
            FileVideoSource fileSource = new FileVideoSource(@"C:\Users\STRIDERA\Videos\ttfatf.wmv");
            OpenVideoSource(fileSource);
        }
 private void bgWorkerUser_DoWork(object sender, DoWorkEventArgs e)
 {
     DateTime dateNow = DateTime.Now;
     parent = db.addVideo(textBoxVideoName.Text, textBoxVideoPath.Text, dateNow.ToString());
     VideoConverter vdc = new VideoConverter();
     path = vdc.Convert(path);
     fileSource = new FileVideoSource(path);
 }
Example #3
0
        // Open video file using DirectShow
        private void openVideofileusingDirectShowToolStripMenuItem_Click( object sender, EventArgs e )
        {
            if ( openFileDialog.ShowDialog( ) == DialogResult.OK )
            {
                // create video source
                FileVideoSource fileSource = new FileVideoSource( openFileDialog.FileName );

                // open it
                OpenVideoSource( fileSource );
            }
        }
Example #4
0
        //private void videoPlayer_NewFrame(object sender, ref Bitmap image)
        //{
        //    if (robustChecking)
        //    {
        //        framesCountedForDetection++;
        //        if (framesCountedForDetection > 5)
        //        {
        //            if (!plateDisplayed && lastCandidate.text != null)
        //            {
        //                if (lastDisplayedPlate.text == null)
        //                {
        //                    main.HandleResults(lastCandidate);
        //                    framesCountedForDetection = 0;
        //                    lastDisplayedPlate = lastCandidate;
        //                    plateDisplayed = false;
        //                }
        //                else if (!lastDisplayedPlate.text.Equals(lastCandidate.text))
        //                {
        //                    main.HandleResults(lastCandidate);
        //                    framesCountedForDetection = 0;
        //                    lastDisplayedPlate = lastCandidate;
        //                    plateDisplayed = false;
        //                }
        //            }
        //        }
        //    }
        //    _motionDetector.ProcessFrame(image);
        //    //force garbage collection since we are using Bitmap's and we
        //    //cant dispose them because of the ref to the video player
        //    //and for some reason it doesn't let go off the resources properly
        //    framesCountedForDisposal++;
        //    if (framesCountedForDisposal == 10)
        //    {
        //        GC.Collect();
        //        framesCountedForDisposal = 0;
        //    }
        //}
        private void loadVideo(String filename)
        {
            lblConnectMessage.Show();
            if (fileVideoSource != null)
            {
                if (fileVideoSource.IsRunning)
                {
                    CloseVideoSource();
                    fileVideoSource.NewFrame += null;
                    setPicture(null);
                    lblConnectMessage.Text = "Connecting to feed...";
                }
            }

            if (File.Exists(filename))
            {
                fileVideoSource = new FileVideoSource(filename);
                fileVideoSource.NewFrame += fileVideoSource_NewFrame;
                lblConnectMessage.Hide();
            }
            else
            {
                lblConnectMessage.Text = "Error connecting to feed";
            }
        }
Example #5
0
 // Constructor
 public Grabber( FileVideoSource parent )
 {
     this.parent = parent;
 }
Example #6
0
        private void PlayRecord(object sender, EventArgs e)
        {
            VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();

            // create new instance of video data analyser
            _videDataAnalyser = new DataAnalyser(_selectedRecord, _selectedRecord.Id);

            // create video source
            FileVideoSource fileSource = new FileVideoSource(_selectedRecord.AbsolutePath);

            // open
            OpenVideoSource(fileSource);
        }
Example #7
0
        private void OpenRecord_Click(object sender, EventArgs e)
        {
            VideoCaptureDeviceForm form = new VideoCaptureDeviceForm();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                // create video source
                FileVideoSource fileSource = new FileVideoSource(openFileDialog.FileName);
                _recordToSave = new Records { AbsolutePath = openFileDialog.FileName };
                // open it
                OpenVideoSource(fileSource);
            }

            if (RecordsGridView.Rows.Count > 0)
            {
                RecordsGridView.CurrentRow.Selected = false;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {

                fileSource = new FileVideoSource(openFileDialog1.FileName);
                textBoxVideoPath.Text = openFileDialog1.FileName;
                textBoxVideoPath.Enabled = false;
                VideoConverter vdc = new VideoConverter();
                path = openFileDialog1.FileName;

            }
        }
Example #9
0
 private void OpenVideofileusingDirectShowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (OpenFileDialog.ShowDialog() == DialogResult.OK)
     {
         var fileSource = new FileVideoSource(OpenFileDialog.FileName);
         OpenVideoSource(fileSource);
     }
 }