Skip to content

IVideoWriter Interface#

Provides a convenient way to save video files.

Syntax#

C#

public interface IVideoWriter : IDisposable

VB

Public Interface IVideoWriter
    Inherits IDisposable

The IVideoWriter type exposes the following members.

Properties#

NameDescription
Public propertyIsOpen Returns the open state of the video file.
 

Methods#

NameDescription
Public methodCanWriteWithoutConversion(IImage) Checks whether the given image can be added to the video file without prior conversion.
Public methodCanWriteWithoutConversion(PixelType, Int32, Int32, Int32, ImageOrientation) Checks whether the given data/image can be added to the video file without prior conversion.
Public methodClose Closes the file.
Public methodCreate(String, Double, ICamera) Creates and opens a file for video writing.
Public methodCreate(String, Double, PixelType, Int32, Int32) Creates and opens a file for video writing.
Public methodWrite(IImage) Adds the image to the video. Converts the image to the correct format if required.
Public methodWrite(T)(T[], PixelType, Int32, Int32, Int32, ImageOrientation) Adds the image to the video. Converts the image to the correct format if required.
 

IVideoWriter.CanWriteWithoutConversion Method (IImage)#

Checks whether the given image can be added to the video file without prior conversion.

Syntax#

C#

bool CanWriteWithoutConversion(
    IImage image
)

VB

Function CanWriteWithoutConversion ( 
    image As IImage
) As Boolean

Parameters#

 

image
Type: Basler.Pylon.IImage
The image to be checked.

Return Value#

Type: Boolean
Returns true if the image can be added to the video stream without prior conversion. Returns false if the image would be automatically converted when Write() is called. Returns false if the image cannot be added at all. See the preconditions of Write() for more information.

Remarks#

IVideoWriter.CanWriteWithoutConversion Method (PixelType, Int32, Int32, Int32, ImageOrientation)#

Checks whether the given data/image can be added to the video file without prior conversion.

Syntax#

C#

bool CanWriteWithoutConversion(
    PixelType pixelType,
    int width,
    int height,
    int paddingX,
    ImageOrientation orientation
)

VB

Function CanWriteWithoutConversion ( 
    pixelType As PixelType,
    width As Integer,
    height As Integer,
    paddingX As Integer,
    orientation As ImageOrientation
) As Boolean

Parameters#

 

pixelType
Type: Basler.Pylon.PixelType
The pixel type of the image.
width
Type: System.Int32
Width of the image.
height
Type: System.Int32
Height of the image.
paddingX
Type: System.Int32
The number of extra data bytes at the end of each row.
orientation
Type: Basler.Pylon.ImageOrientation
Orientation of the image.

Return Value#

Type: Boolean
Returns true if the image can be added to the video stream without prior conversion. Returns false if the image would be automatically converted when Write() is called. Returns false if the image cannot be added at all. See the preconditions of Write() for more information.

Remarks#

Thread Safety: This method is thread-safe.

IVideoWriter.Close Method#

Closes the file.

Syntax#

C#

void Close()

VB

Sub Close

Remarks#

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.

IVideoWriter.Create Method (String, Double, ICamera)#

Creates and opens a file for video writing.

Syntax#

C#

void Create(
    string filename,
    double playbackFramesPerSecond,
    ICamera camera
)

VB

Sub Create ( 
    filename As String,
    playbackFramesPerSecond As Double,
    camera As ICamera
)

Parameters#

 

filename
Type: System.String
File name of the video file to be created. Existing files will be overwritten.
playbackFramesPerSecond
Type: System.Double
Playback speed in frames per second.
camera
Type: Basler.Pylon.ICamera
The camera from which the current settings are read.

Remarks#

This overload reads the PixelType, Width, and Height parameters from the camera passed. Default compression options appropriate for the format will be chosen.

Preconditions:  

  • The file is writable.
  • The camera must be open.
  • Depending on the video format used, not all pixel types may be supported.
  Thread Safety: This method is thread-safe.

Error Safety: Can throw exceptions if the file cannot be created successfully or the preconditions are not met.

IVideoWriter.Create Method (String, Double, PixelType, Int32, Int32)#

Creates and opens a file for video writing.

Syntax#

C#

void Create(
    string filename,
    double playbackFramesPerSecond,
    PixelType pixelType,
    int width,
    int height
)

VB

Sub Create ( 
    filename As String,
    playbackFramesPerSecond As Double,
    pixelType As PixelType,
    width As Integer,
    height As Integer
)

Parameters#

 

filename
Type: System.String
File name of the video file to be created. Existing files will be overwritten.
playbackFramesPerSecond
Type: System.Double
Playback speed in frames per second.
pixelType
Type: Basler.Pylon.PixelType
The pixel type of the images that will be added to the video writer. This input is used to derive the video format.
width
Type: System.Int32
Width of the video.
height
Type: System.Int32
Height of the video.

Remarks#

Default compression options appropriate for the format will be used.

Preconditions:  

  • The file is writable.
  • Depending on the video format used, not all pixel types may be supported.
  • width and height must be greater than 0.
  Thread Safety: This method is thread-safe.

Error Safety: Can throw exceptions if the file cannot be created successfully or the preconditions are not met.

IVideoWriter.Write Method (IImage)#

Adds the image to the video. Converts the image to the correct format if required.

Syntax#

C#

void Write(
    IImage image
)

VB

Sub Write ( 
    image As IImage
)

Parameters#

 

image
Type: Basler.Pylon.IImage
The image to be added.

Remarks#

If required, the image is automatically converted to the target format.

Preconditions  

  • Create() has been called successfully.
  • The image passed is valid.
  • The pixel type of the image to add is a format supported by pylon.
  • The width and height of the image match the values passed when opening the video file.
  Thread Safety: This method is thread-safe.

Error Safety: Throws an exception if the image cannot be added.

IVideoWriter.Write(T) Method (T[], PixelType, Int32, Int32, Int32, ImageOrientation)#

Adds the image to the video. Converts the image to the correct format if required.

Syntax#

C#

void Write<T>(
    T[] pixelData,
    PixelType pixelType,
    int width,
    int height,
    int paddingX,
    ImageOrientation orientation
)

VB

Sub Write(Of T) ( 
    pixelData As T(),
    pixelType As PixelType,
    width As Integer,
    height As Integer,
    paddingX As Integer,
    orientation As ImageOrientation
)

Parameters#

 

pixelData
Type: T[]
The data of the image to be added.
pixelType
Type: Basler.Pylon.PixelType
The pixel type of the image.
width
Type: System.Int32
Width of the image.
height
Type: System.Int32
Height of the image.
paddingX
Type: System.Int32
The number of extra data bytes at the end of each row.
orientation
Type: Basler.Pylon.ImageOrientation
Orientation of the video. Most codecs support ImageOrientation.BottomUp only.

Type Parameters#

 

T
The data type of pixels stored in pixelData.

Remarks#

If required, the image is automatically converted to the target format.

Preconditions  

  • Create() has been called successfully.
  • The image passed is valid.
  • The pixel type of the image to add is a format supported by pylon.
  • The width and height of the image match the values passed when opening the video file.
  Thread Safety: This method is thread-safe.

Error Safety: Throws an exception if the image cannot be added.

IVideoWriter.CanWriteWithoutConversion Method#

Overload List#

NameDescription
Public methodCanWriteWithoutConversion(IImage) Checks whether the given image can be added to the video file without prior conversion.
Public methodCanWriteWithoutConversion(PixelType, Int32, Int32, Int32, ImageOrientation) Checks whether the given data/image can be added to the video file without prior conversion.
 

IVideoWriter.Create Method#

Overload List#

NameDescription
Public methodCreate(String, Double, ICamera) Creates and opens a file for video writing.
Public methodCreate(String, Double, PixelType, Int32, Int32) Creates and opens a file for video writing.
 

IVideoWriter.Write Method#

Overload List#

NameDescription
Public methodWrite(IImage) Adds the image to the video. Converts the image to the correct format if required.
Public methodWrite(T)(T[], PixelType, Int32, Int32, Int32, ImageOrientation) Adds the image to the video. Converts the image to the correct format if required.
 

IVideoWriter.IsOpen Property#

Returns the open state of the video file.

Syntax#

C#

bool IsOpen { get; }

VB

ReadOnly Property IsOpen As Boolean
    Get

Return Value#

Type: Boolean
Returns true if a file for video output has been opened.

Remarks#

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.