Class VideoWriter

Represents a video writer

Inheritance

VideoWriter

Implements

Namespace: ic4
Assembly: ic4dotnet.dll
Syntax
public class VideoWriter : HandleObject, IDisposable
Remarks

To create a video writer, use the VideoWriter(VideoWriterType) constructor, passing the type of the desired video file.

After creating the video writer, call BeginFile(string, ImageType, double) to start writing a new video file. Call AddFrame(ImageBuffer) to add images to the video file. To complete the recording, call FinishFile().

Use PropertyMap to access encoder configuration options.

Constructors

VideoWriter(VideoWriterType)

Creates a new video writer.

Declaration

public VideoWriter(VideoWriterType type)

Parameters

Type Name Description
VideoWriterType type

The type of video file to create a writer for

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

Properties

PropertyMap

The video writer's property map for encoder configuration

Declaration

public PropertyMap PropertyMap { get; }
Property Value
Type Description
PropertyMap

The video writer's property map

Exceptions

Type Condition
IC4Exception

Check ErrorCode and ToString() for details.

Methods

AddFrame(ImageBuffer)

Adds an image to the currently open video file.

Declaration

public void AddFrame(ImageBuffer buffer)

Parameters

Type Name Description
ImageBuffer buffer

Image buffer to be added to the video file

Remarks

BeginFile(string, ImageType, double) must be called before adding images to the video file.

The image buffer's ImageType must be equal to the imageType parameter passed to BeginFile(string, ImageType, double) when starting the file.

The video writer can retain a reference to the image buffer. This can delay the release and possible reuse of the image buffer. In this case, the buffer becomes shared, and is no longer safely writable (IsWritable). Use AddFrameCopy(ImageBuffer) to always let the video writer immediately copy the data out of the image buffer.

Exceptions

Type Condition
ArgumentNullException

buffer is null.

InvalidOperationException

BeginFile(string, ImageType, double) was not called.

IC4Exception

Check ErrorCode and ToString() for details.

AddFrameCopy(ImageBuffer)

Adds an image to the currently open video file, copying the image data in the process.

Declaration

public void AddFrameCopy(ImageBuffer buffer)

Parameters

Type Name Description
ImageBuffer buffer

Image buffer to be added to the video file

Remarks

BeginFile(string, ImageType, double) must be called before adding images to the video file.

The image buffer's ImageType must be equal to the imageType parameter passed to BeginFile(string, ImageType, double) when starting the file.

The image buffer's contents will be copied, so that the buffer's reference count is not increased and it can be reused immedietely if the final reference is released. Use AddFrame(ImageBuffer) to avoid the copy operation if it is not necessary.

Exceptions

Type Condition
ArgumentNullException

buffer is null.

InvalidOperationException

BeginFile(string, ImageType, double) was not called.

IC4Exception

Check ErrorCode and ToString() for details.

BeginFile(string, ImageType, double)

Opens a new video file ready to write images into.

Declaration

public void BeginFile(string fileName, ImageType imageType, double frameRate)

Parameters

Type Name Description
string fileName

Name of the new video file

ImageType imageType

Image type of the images that are going to be written

double frameRate

Playback frame rate of the video file

Exceptions

Type Condition
ArgumentNullException
InvalidOperationException

BeginFile was already called without a matching call to FinishFile().

IC4Exception

Check ErrorCode and ToString() for details.

FinishFile()

Finishes writing a video file.

Declaration

public void FinishFile()

Exceptions

Type Condition
InvalidOperationException

BeginFile(string, ImageType, double) was not called.

IC4Exception

Check ErrorCode and ToString() for details.

Implements