AForge.Video.VFW
AVI file video source.
The video source reads AVI files using Video for Windows.
Sample usage:
// create AVI file video source
AVIFileVideoSource source = new AVIFileVideoSource( "some file" );
// set event handlers
source.NewFrame += new NewFrameEventHandler( video_NewFrame );
// start the video source
source.Start( );
// ...
// signal to stop
source.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
}
New frame event.
Notifies clients about new available frame from video source.
Since video source may have multiple clients, each client is responsible for
making a copy (cloning) of the passed video frame, because the video source disposes its
own original copy after notifying of clients.
Video source error event.
This event is used to notify clients about any type of errors occurred in
video source object, for example internal exceptions.
Video playing finished event.
This event is used to notify clients that the video playing has finished.
Frame interval.
The property sets the interval in milliseconds between frames. If the property is
set to 100, then the desired frame rate will be 10 frames per second.
Setting this property to 0 leads to no delay between video frames - frames
are read as fast as possible.
Default value is set to 0.
Get frame interval from source or use manually specified.
The property specifies which frame rate to use for video playing.
If the property is set to , then video is played
with original frame rate, which is set in source AVI file. If the property is
set to , then custom frame rate is used, which is
calculated based on the manually specified frame interval.
Default value is set to .
Video source.
Video file name to play.
Received frames count.
Number of frames the video source provided from the moment of the last
access to the property.
Received bytes count.
Number of bytes the video source provided from the moment of the last
access to the property.
State of the video source.
Current state of video source object - running or not.
Initializes a new instance of the class.
Initializes a new instance of the class.
Video file name.
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 event.
Video source is not specified.
Signal video source to stop its work.
Signals video source to stop its background thread, stop to
provide new frames and free resources.
Wait for video source has stopped.
Waits for source stopping after it was signalled to stop using
method.
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.
Free resource.
Worker thread.
AVI files reading using Video for Windows.
The class allows to read AVI files using Video for Windows API.
Sample usage:
// instantiate AVI reader
AVIReader reader = new AVIReader( );
// open video file
reader.Open( "test.avi" );
// read the video file
while ( reader.Position - reader.Start < reader.Length )
{
// get next frame
Bitmap image = reader.GetNextFrame( );
// .. process the frame somehow or display it
}
reader.Close( );
Width of video frames.
The property specifies the width of video frames within the opened video
file.
Height of video frames.
The property specifies the height of video frames within the opened video
file.
Current position in video stream.
Setting position outside of video range, will lead to reseting position to the start.
Starting position of video stream.
Video stream length.
Desired playing frame rate.
The property specifies the frame rate, which should be used to play the opened video
file.
Codec used for video compression.
The property tells about which codec was used to encode the opened video file.
Initializes a new instance of the class.
Initializes Video for Windows library.
Destroys the instance of the class.
Dispose the object.
Frees unmanaged resources used by the object. The object becomes unusable
after that.
Dispose the object.
Indicates if disposing was initiated manually.
Open AVI file.
AVI file name to open.
The method opens a video file and prepares the stream and decoder for
reading video frames with the help of method.
Failed opening the specified file.
A error occurred while opening the video file. See exception message.
Close video file.
Get next frame of opened video stream.
Returns next frame as a bitmap.
The method reads and returns the next video frame in the opened video stream
at the position, which is set in property.
Thrown if no video file was open.
A error occurred while reading next video frame. See exception message.
AVI files writing using Video for Windows interface.
The class allows to write AVI files using Video for Windows API.
Sample usage:
// instantiate AVI writer, use WMV3 codec
AVIWriter writer = new AVIWriter( "wmv3" );
// create new AVI file and open it
writer.Open( "test.avi", 320, 240 );
// create frame image
Bitmap image = new Bitmap( 320, 240 );
for ( int i = 0; i < 240; i++ )
{
// update image
image.SetPixel( i, i, Color.Red );
// add the image as a new frame of video file
writer.AddFrame( image );
}
writer.Close( );
Width of video frames.
The property specifies the width of video frames, which are acceptable
by method for saving, which is set in
method.
Height of video frames.
The property specifies the height of video frames, which are acceptable
by method for saving, which is set in
method.
Current position in video stream.
The property tell current position in video stream, which actually equals
to the amount of frames added using method.
Desired playing frame rate.
The property sets the video frame rate, which should be use during playing
of the video to be saved.
The property should be set befor opening new file to take effect.
Default frame rate is set to 25.
Codec used for video compression.
The property sets the FOURCC code of video compression codec, which needs to
be used for video encoding.
The property should be set befor opening new file to take effect.
Default video codec is set "DIB ", which means no compression.
Compression video quality.
The property sets video quality used by codec in order to balance compression rate
and image quality. The quality is measured usually in the [0, 100] range.
The property should be set befor opening new file to take effect.
Default value is set to -1 - default compression quality of the codec.
Initializes a new instance of the class.
Initializes Video for Windows library.
Initializes a new instance of the class.
Codec to use for compression.
Initializes Video for Windows library.
Destroys the instance of the class.
Dispose the object.
Frees unmanaged resources used by the object. The object becomes unusable
after that.
Dispose the object.
Indicates if disposing was initiated manually.
Create new AVI file and open it for writing.
AVI file name to create.
Video width.
Video height.
The method opens (creates) a video files, configure video codec and prepares
the stream for saving video frames with a help of method.
Failed opening the specified file.
A error occurred while creating new video file. See exception message.
Insufficient memory for internal buffer.
Video file resolution must be a multiple of two.
Close video file.
Add new frame to the AVI file.
New frame image.
The method adds new video frame to an opened video file. The width and heights
of the frame should be the same as it was specified in method
(see and properties).
Thrown if no video file was open.
Bitmap size must be of the same as video size, which was specified on opening video file.
A error occurred while writing new video frame. See exception message.
Windows API functions and structures.
The class provides Video for Windows and some other Win32 functions and structurs.
Copy a block of memory.
Destination pointer.
Source pointer.
Memory block's length to copy.
Return's the value of dst - pointer to destination.
Initialize the AVIFile library.
Exit the AVIFile library.
Open an AVI file.
Opened AVI file interface.
AVI file name.
Opening mode (see ).
Handler to use (null to use default).
Returns zero on success or error code otherwise.
Release an open AVI stream.
Open AVI file interface.
Returns the reference count of the file.
Get stream interface that is associated with a specified AVI file
Handler to an open AVI file.
Stream interface.
Stream type to open.
Count of the stream type. Identifies which occurrence of the specified stream type to access.
Create a new stream in an existing file and creates an interface to the new stream.
Handler to an open AVI file.
Stream interface.
Pointer to a structure containing information about the new stream.
Returns zero if successful or an error otherwise.
Release an open AVI stream.
Handle to an open stream.
Returns the current reference count of the stream.
Set the format of a stream at the specified position.
Handle to an open stream.
Position in the stream to receive the format.
Pointer to a structure containing the new format.
Size, in bytes, of the block of memory referenced by format.
Returns zero if successful or an error otherwise.
Get the starting sample number for the stream.
Handle to an open stream.
Returns the number if successful or ?1 otherwise.
Get the length of the stream.
Handle to an open stream.
Returns the stream's length, in samples, if successful or -1 otherwise.
Obtain stream header information.
Handle to an open stream.
Pointer to a structure to contain the stream information.
Size, in bytes, of the structure used for streamInfo.
Returns zero if successful or an error otherwise.
Prepare to decompress video frames from the specified video stream
Pointer to the video stream used as the video source.
Pointer to a structure that defines the desired video format. Specify NULL to use a default format.
Returns an object that can be used with the function.
Prepare to decompress video frames from the specified video stream.
Pointer to the video stream used as the video source.
Pointer to a structure that defines the desired video format. Specify NULL to use a default format.
Returns a GetFrame object that can be used with the function.
Releases resources used to decompress video frames.
Handle returned from the function.
Returns zero if successful or an error otherwise.
Return the address of a decompressed video frame.
Pointer to a GetFrame object.
Position, in samples, within the stream of the desired frame.
Returns a pointer to the frame data if successful or NULL otherwise.
Write data to a stream.
Handle to an open stream.
First sample to write.
Number of samples to write.
Pointer to a buffer containing the data to write.
Size of the buffer referenced by buffer.
Flag associated with this data.
Pointer to a buffer that receives the number of samples written. This can be set to NULL.
Pointer to a buffer that receives the number of bytes written. This can be set to NULL.
Returns zero if successful or an error otherwise.
Retrieve the save options for a file and returns them in a buffer.
Handle to the parent window for the Compression Options dialog box.
Flags for displaying the Compression Options dialog box.
Number of streams that have their options set by the dialog box.
Pointer to an array of stream interface pointers.
Pointer to an array of pointers to AVICOMPRESSOPTIONS structures.
Returns TRUE if the user pressed OK, FALSE for CANCEL, or an error otherwise.
Free the resources allocated by the AVISaveOptions function.
Count of the AVICOMPRESSOPTIONS structures referenced in options.
Pointer to an array of pointers to AVICOMPRESSOPTIONS structures.
Returns 0.
Create a compressed stream from an uncompressed stream and a
compression filter, and returns the address of a pointer to
the compressed stream.
Pointer to a buffer that receives the compressed stream pointer.
Pointer to the stream to be compressed.
Pointer to a structure that identifies the type of compression to use and the options to apply.
Pointer to a class identifier used to create the stream.
Returns 0 if successful or an error otherwise.
Structure to define the coordinates of the upper-left and
lower-right corners of a rectangle.
x-coordinate of the upper-left corner of the rectangle.
y-coordinate of the upper-left corner of the rectangle.
x-coordinate of the bottom-right corner of the rectangle.
y-coordinate of the bottom-right corner of the rectangle.
Structure, which contains information for a single stream .
Four-character code indicating the stream type.
Four-character code of the compressor handler that will compress this video stream when it is saved.
Applicable flags for the stream.
Capability flags; currently unused.
Priority of the stream.
Language of the stream.
Time scale applicable for the stream.
Dividing rate by scale gives the playback rate in number of samples per second.
Rate in an integer format.
Sample number of the first frame of the AVI file.
Length of this stream.
The units are defined by rate and scale.
Audio skew. This member specifies how much to skew the audio data ahead of the video frames in interleaved files.
Recommended buffer size, in bytes, for the stream.
Quality indicator of the video data in the stream.
Quality is represented as a number between 0 and 10,000.
Size, in bytes, of a single data sample.
Dimensions of the video destination rectangle.
Number of times the stream has been edited.
Number of times the stream format has changed.
Description of the stream.
Structure, which contains information about the dimensions and color format of a DIB.
Specifies the number of bytes required by the structure.
Specifies the width of the bitmap, in pixels.
Specifies the height of the bitmap, in pixels.
If height is positive, the bitmap is a bottom-up DIB and its origin is
the lower-left corner. If height is negative, the bitmap is a top-down DIB and its
origin is the upper-left corner.
Specifies the number of planes for the target device. This value must be set to 1.
Specifies the number of bits-per-pixel.
Specifies the type of compression for a compressed bottom-up bitmap (top-down DIBs cannot be compressed).
Specifies the size, in bytes, of the image.
Specifies the horizontal resolution, in pixels-per-meter, of the target device for the bitmap.
Specifies the vertical resolution, in pixels-per-meter, of the target device for the bitmap.
Specifies the number of color indexes in the color table that are actually used by the bitmap.
Specifies the number of color indexes that are required for displaying the bitmap.
Structure, which contains information about a stream and how it is compressed and saved.
Four-character code indicating the stream type.
Four-character code for the compressor handler that will compress this video stream when it is saved.
Maximum period between video key frames.
Quality value passed to a video compressor.
Video compressor data rate.
Flags used for compression.
Pointer to a structure defining the data format.
Size, in bytes, of the data referenced by format.
Video-compressor-specific data; used internally.
Size, in bytes, of the data referenced by parameters.
Interleave factor for interspersing stream data with data from the first stream.
File access modes.
.NET replacement of mmioFOURCC macros. Converts four characters to code.
Four characters string.
Returns the code created from provided characters.
Inverse to . Converts code to fout characters string.
Code to convert.
Returns four characters string.
Version of for one stream only.
Stream to configure.
Stream options.
Returns TRUE if the user pressed OK, FALSE for CANCEL, or an error otherwise.