C# Класс AForge.Video.DirectShow.FileVideoSource

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 }
Наследование: IVideoSource
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
FileVideoSource ( ) : System

Initializes a new instance of the FileVideoSource class.

FileVideoSource ( string fileName ) : System

Initializes a new instance of the FileVideoSource class.

SignalToStop ( ) : void

Signal video source to stop its work.

Signals video source to stop its background thread, stop to provide new frames and free resources.

Start ( ) : void

Start video source.

Starts video source and return execution to caller. Video source object creates background thread and notifies about new frames with the help of NewFrame event.

Stop ( ) : void

Stop video source.

Stops video source aborting its thread.

Since the method aborts background thread, its usage is highly not preferred and should be done only if there are no other options. The correct way of stopping camera is signaling it stop and then waiting for background thread's completion.

WaitForStop ( ) : void

Wait for video source has stopped.

Waits for source stopping after it was signalled to stop using SignalToStop method.

Защищенные методы

Метод Описание
OnNewFrame ( Bitmap image ) : void

Notifies client about new frame.

Приватные методы

Метод Описание
Free ( ) : void

Free resource.

WorkerThread ( ) : void

Worker thread.

Описание методов

FileVideoSource() публичный Метод

Initializes a new instance of the FileVideoSource class.
public FileVideoSource ( ) : System
Результат System

FileVideoSource() публичный Метод

Initializes a new instance of the FileVideoSource class.
public FileVideoSource ( string fileName ) : System
fileName string Video file name.
Результат System

OnNewFrame() защищенный Метод

Notifies client about new frame.
protected OnNewFrame ( Bitmap image ) : void
image System.Drawing.Bitmap New frame's image.
Результат void

SignalToStop() публичный Метод

Signal video source to stop its work.
Signals video source to stop its background thread, stop to provide new frames and free resources.
public SignalToStop ( ) : void
Результат void

Start() публичный Метод

Start video source.
Starts video source and return execution to caller. Video source object creates background thread and notifies about new frames with the help of NewFrame event.
public Start ( ) : void
Результат void

Stop() публичный Метод

Stop video source.

Stops video source aborting its thread.

Since the method aborts background thread, its usage is highly not preferred and should be done only if there are no other options. The correct way of stopping camera is signaling it stop and then waiting for background thread's completion.

public Stop ( ) : void
Результат void

WaitForStop() публичный Метод

Wait for video source has stopped.
Waits for source stopping after it was signalled to stop using SignalToStop method.
public WaitForStop ( ) : void
Результат void