Skip to content

VideoWriter Class#

Provides a convenient way to save video files using the pylon Supplementary Package for MPEG-4.

Inheritance Hierarchy#

System.Object
  Basler.Pylon.VideoWriter

Syntax#

C#

public class VideoWriter : IVideoWriter

VB

Public Class VideoWriter
    Implements IVideoWriter

The VideoWriter type exposes the following members.

Constructors#

NameDescription
Public methodVideoWriter Initializes a new instance of the VideoWriter class.
 

Properties#

NameDescription
Public propertyImageDataBytesWritten Returns the amount of image data written to the video file in bytes.
Public propertyIsOpen Returns the open state of the video file.
Public propertyStatic memberIsSupported Checks if video writing is supported.
Public propertyParameters Returns the parameter collection of the video writer for accessing all parameters. Example: videowriter.Parameters[PLVideoWriter.BytesWritten].GetValue();
 

Methods#

NameDescription
Public methodCanWriteWithoutConversion(IImage) Checks whether the image passed 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 methodCreate(String, Double, PixelType, Int32, Int32, UInt32) Creates and opens a file for video writing.
Public methodDispose Releases all resources used by the VideoWriter
Public methodWrite(IImage) Writes an image to the video.
Public methodWrite(T)(T[], PixelType, Int32, Int32, Int32, ImageOrientation) Writes the image to the video.
 

VideoWriter.CanWriteWithoutConversion Method (IImage)#

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

Syntax#

C#

public virtual bool CanWriteWithoutConversion(
    IImage image
)

VB

Public Overridable Function CanWriteWithoutConversion ( 
    image As IImage
) As Boolean

Parameters#

 

image
Type: Basler.Pylon.IImage
Image or grabresult to check.

Return Value#

Type: Boolean
Returns true if the image will added to the video stream without prior conversion when Write() is called. Returns false if the image will 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.

Implements#

IVideoWriter.CanWriteWithoutConversion(IImage)

Remarks#

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.

VideoWriter.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#

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

VB

Public Overridable 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 video. Most codecs support ImageOrientation.BottomUp only.

Return Value#

Type: Boolean
Returns true if the image will added to the video stream without prior conversion when Write() is called. Returns false if the image will 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.

Implements#

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

Remarks#

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.

VideoWriter.Close Method#

Closes the file.

Syntax#

C#

public virtual void Close()

VB

Public Overridable Sub Close

Implements#

IVideoWriter.Close()

Remarks#

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.

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

Creates and opens a file for video writing.

Syntax#

C#

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

VB

Public Overridable 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. If the file doesn't have the an extension, .mp4 will be appended automatically. 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.

Implements#

IVideoWriter.Create(String, Double, ICamera)

Remarks#

This overload reads the PixelType, Width, and Height parameters from the camera passed.

Preconditions:  

  • The file is writable.
  • The camera must be open.
  • The pixel type must be supported by the image format converter.
  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.

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

Creates and opens a file for video writing.

Syntax#

C#

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

VB

Public Overridable 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. If the file doesn't have the an extension, .mp4 will be appended automatically. 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. Currently, the output is always YUV420p.
width
Type: System.Int32
Width of the video.
height
Type: System.Int32
Height of the video.

Implements#

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

Remarks#

Preconditions:  

  • The file is writable.
  • width and height must be greater than 0.
  • pixelType is supported by the image format converter.
  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.

VideoWriter.Create Method (String, Double, PixelType, Int32, Int32, UInt32)#

Creates and opens a file for video writing.

Syntax#

C#

public virtual void Create(
    string filename,
    double playbackFramesPerSecond,
    PixelType pixelType,
    int width,
    int height,
    uint quality
)

VB

Public Overridable Sub Create ( 
    filename As String,
    playbackFramesPerSecond As Double,
    pixelType As PixelType,
    width As Integer,
    height As Integer,
    quality As UInteger
)

Parameters#

 

filename
Type: System.String
File name of the video file to be created. If the file doesn't have the an extension, .mp4 will be appended automatically. 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. Currently, the output is always YUV420p.
width
Type: System.Int32
Width of the video.
height
Type: System.Int32
Height of the video.
quality
Type: System.UInt32
Quality of the video.

Remarks#

Preconditions:  

  • The file is writable.
  • pixelType is supported by the image format converter.
  • width and height must be greater than 0.
  • quality must be in the range 1 … 100.
  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.

VideoWriter.Dispose Method#

Releases all resources used by the VideoWriter

Syntax#

C#

public void Dispose()

VB

Public Sub Dispose

VideoWriter.Write Method (IImage)#

Writes an image to the video.

Syntax#

C#

public virtual void Write(
    IImage image
)

VB

Public Overridable Sub Write ( 
    image As IImage
)

Parameters#

 

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

Implements#

IVideoWriter.Write(IImage)

Remarks#

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

Preconditions
 
  • The file is open.
  • The image is valid.
  • The pixel type of the image is 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: Does not throw exceptions.

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

Writes the image to the video.

Syntax#

C#

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

VB

Public Overridable 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 written.
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 in pixelData
orientation
Type: Basler.Pylon.ImageOrientation
Orientation of the image data in pixelData.

Type Parameters#

 

T
The data type of pixels stored in pixelData.

Implements#

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

Remarks#

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

Preconditions  

  • The file is open.
  • The pixel type of the image is 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: Does not throw exceptions.

VideoWriter Constructor#

Initializes a new instance of the VideoWriter class.

Syntax#

C#

public VideoWriter()

VB

Public Sub New

Remarks#

Creates and initializes a new instance of the VideoWriter class.

Error Safety: Can throw exceptions.

VideoWriter.CanWriteWithoutConversion Method#

Overload List#

NameDescription
Public methodCanWriteWithoutConversion(IImage) Checks whether the image passed 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.
 

VideoWriter.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.
Public methodCreate(String, Double, PixelType, Int32, Int32, UInt32) Creates and opens a file for video writing.
 

VideoWriter.Write Method#

Overload List#

NameDescription
Public methodWrite(IImage) Writes an image to the video.
Public methodWrite(T)(T[], PixelType, Int32, Int32, Int32, ImageOrientation) Writes the image to the video.
 

VideoWriter.ImageDataBytesWritten Property#

Returns the amount of image data written to the video file in bytes.

Syntax#

C#

public long ImageDataBytesWritten { get; }

VB

Public ReadOnly Property ImageDataBytesWritten As Long
    Get

Property Value#

Type: Int64

Remarks#

This value is updated with each call to Write().

Return Value#

Type: Int64
Returns the amount of image data bytes that have been written to the file. Returns 0 if no images have been written yet.

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.

VideoWriter.IsOpen Property#

Returns the open state of the video file.

Syntax#

C#

public virtual bool IsOpen { get; }

VB

Public Overridable ReadOnly Property IsOpen As Boolean
    Get

Return Value#

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

Implements#

IVideoWriter.IsOpen

Remarks#

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.

VideoWriter.IsSupported Property#

Checks if video writing is supported.

Syntax#

C#

public static bool IsSupported { get; }

VB

Public Shared ReadOnly Property IsSupported As Boolean
    Get

Property Value#

Type: Boolean

Remarks#

Checks if all neccessary dynamic libraries are installed and can be loaded. This does not check if the codec for the video can be used. This is checked in Create().

Return Value#

Type: Boolean
Returns true if supported (i.e. all DLLs are okay and can be loaded)

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.

VideoWriter.Parameters Property#

Returns the parameter collection of the video writer for accessing all parameters. Example: videowriter.Parameters[PLVideoWriter.BytesWritten].GetValue();

Syntax#

C#

public IParameterCollection Parameters { get; }

VB

Public ReadOnly Property Parameters As IParameterCollection
    Get

Return Value#

Type: IParameterCollection
Returns the parameter collection of the video writer.

Remarks#

You can use the parameter collection to configure the video writer through parameters. You can access parameters by their name or predefined parameter list.

Currently the only predefined parameter list is:  

  • PLVideoWriter
  For more information about the parameters, see the documentation for the parameter list.

You can access parameters by passing a key from a parameter list to the index operator, e.g. C#

videowriter.Parameters[PLVideoWriter.BytesWritten].GetValue();

Thread Safety: This method is thread-safe.

Error Safety: Does not throw exceptions.