Skip to content

Pylon::CVideoWriter#

Supports writing video files. More…

#include <pylon/VideoWriter.h>

Inherits from Basler_VideoWriterParams::CVideoWriterParams_Params, Basler_VideoWriterParams::CVideoWriterParams_Params_v9_0_0

Public Functions#

Name
CVideoWriter()
Creates a video writer object.
virtual ~CVideoWriter()
Destroys the video writer object.
virtual void SetParameter(uint32_t width, uint32_t height, EPixelType inputPixelType, double framesPerSecondPlaybackSpeed, uint32_t quality)
Easy way to set parameters required for video recording.
virtual void Open(const Pylon::String_t & filename)
Opens a video file for writing.
virtual bool IsOpen() const
Returns the open state of the video file.
virtual void Close()
Closes the video file.
virtual void Add(const void * pBuffer, size_t bufferSize, Pylon::EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, Pylon::EImageOrientation orientation)
Adds the image to the video file.
virtual void Add(const Pylon::IImage & image)
Adds the image to the video file.
virtual bool CanAddWithoutConversion(Pylon::EPixelType pixelType, uint32_t width, uint32_t height, size_t paddingX, Pylon::EImageOrientation orientation)
Can be used to check whether the given image is added to the video file without prior conversion when Add() is called.
virtual bool CanAddWithoutConversion(const Pylon::IImage & image)
Can be used to check whether the given image is added to the video file without prior conversion when Add() is called.
virtual GenApi::INodeMap & GetNodeMap()
Provides access to all parameters via a nodemap.
bool IsSupported()
Checks if video writing is supported.

Protected Functions#

Name
CLock & GetLock()
Provides access to the lock used for synchronizing the access to the video writer.

Public Attributes#

Name
Pylon::IIntegerEx & Bitrate
Bit rate of the resulting compressed stream.
Pylon::IEnumParameterT< CompressionModeEnums > & CompressionMode
Sets the compression mode.
Pylon::IFloatEx & PlaybackFrameRate
Frame rate (in Hertz) of the video to be recorded.
Pylon::IFloatEx & Quality
Quality of the resulting compressed stream.
Pylon::IIntegerEx & ThreadCount
Number of threads used for recording the video.
Pylon::IIntegerEx & BytesWritten
Bytes written to file since starting the recording.
Pylon::IIntegerEx & FrameCount
Number of frames written since starting the recording.
Pylon::IIntegerEx & Height
Height of the image (in pixels)
Pylon::IIntegerEx & Width
Width of the image (in pixels)

Detailed Description#

class Pylon::CVideoWriter;

Supports writing video files.

Note Note that a supplementary software package containing additional libraries has to be installed for this.

Public Functions Documentation#

function CVideoWriter#

CVideoWriter()

Creates a video writer object.

Error Safety:

Throws a RuntimeException when no memory can be allocated.

function ~CVideoWriter#

virtual ~CVideoWriter()

Destroys the video writer object.

Error Safety:

Does not throw C++ exceptions.

function SetParameter#

virtual void SetParameter(
    uint32_t width,
    uint32_t height,
    EPixelType inputPixelType,
    double framesPerSecondPlaybackSpeed,
    uint32_t quality
)

Easy way to set parameters required for video recording.

Parameters:

  • width The number of pixels in a row of the video file to save.
  • height The number of rows of the video file to save.
  • inputPixelType 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.
  • framesPerSecondPlaybackSpeed The playback speed in frames per second.
  • quality The quality setting, valid range is 1 … 100.

Precondition: The VideoWriter ist closed.

Error Safety:

Throws a C++ exception when a parameter is out of range, set to an invalid value or parameters cannot be changed (e.g., after calling Open()).

This is a convenient way to set all required parameters in a single function call. The parameters width, height, framesPerSecondPlaybackSpeed and quality are set in the nodemap. The parameter inputPixelType is checked for its convertibility to YUV420p or whether it is already YUV420p. Advanced parameters can be accessed using the nodemap provided by GetNodeMap().

function Open#

virtual void Open(
    const Pylon::String_t & filename
)

Opens a video file for writing.

Parameters:

  • filename Name and path of the video file.

Precondition:

  • The VideoWriter ist closed.
  • The width and height parameters are larger than 1.

Error Safety:

Throws an exception if the video file cannot be opened. Throws an exception if the current parameters do not meet codec requirements.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

If a file with the same filename already exists, it will be overwritten.

function IsOpen#

virtual bool IsOpen() const

Returns the open state of the video file.

Return: Returns true if open.

Error Safety:

Does not throw C++ exceptions.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

function Close#

virtual void Close()

Closes the video file.

Error Safety:

Does not throw C++ exceptions.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

function Add#

virtual void Add(
    const void * pBuffer,
    size_t bufferSize,
    Pylon::EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    Pylon::EImageOrientation orientation
)

Adds the image to the video file.

Parameters:

  • pBuffer The pointer to the buffer of the image.
  • bufferSize The size of the buffer in byte.
  • pixelType The pixel type of the image to save.
  • width The number of pixels in a row of the image to save.
  • height The number of rows of the image to save.
  • paddingX The number of extra data bytes at the end of each line.
  • orientation The vertical orientation of the image in the image buffer.

Precondition:

  • The file is open.
  • The image added is valid.
  • The pixelType of the image to add is a supported input format of the Pylon::CImageFormatConverter or YUV420p.
  • If the pixelType is YUV420p the orientation has to be ImageOrientation_TopDown.
  • The width and height of the image match the values passed when opening the video file.

Error Safety:

Throws an exception if the image cannot be added.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

Converts the image to the correct format if required.

The image is automatically converted to YUV420p unless the input pixelType is already YUV420p. The orientation of the image is always converted to ImageOrientation_TopDown unless the inputpixelType is YUV420p. In that case, the orientation of the image must already be ImageOrientation_TopDown. See preconditions.

function Add#

virtual void Add(
    const Pylon::IImage & image
)

Adds the image to the video file.

Parameters:

Precondition:

  • The file is open.
  • The image added is valid.
  • The pixelType of the image to add is a supported input format of the Pylon::CImageFormatConverter or YUV420p.
  • If the pixelType is YUV420p the orientation has to be ImageOrientation_TopDown.
  • The width and height of the image match the values passed when opening the video file.

Error Safety:

Throws an exception if the image cannot be added.

Thread Safety:

This method is synchronized using the lock provided by GetLock().

Converts the image to the correct format if required.

The image is automatically converted to YUV420p unless the input pixelType is already YUV420p. The orientation of the image is always converted to ImageOrientation_TopDown unless the input pixelType is YUV420p. In that case, the orientation of the image must already be ImageOrientation_TopDown. See preconditions.

function CanAddWithoutConversion#

virtual bool CanAddWithoutConversion(
    Pylon::EPixelType pixelType,
    uint32_t width,
    uint32_t height,
    size_t paddingX,
    Pylon::EImageOrientation orientation
)

Can be used to check whether the given image is added to the video file without prior conversion when Add() is called.

Parameters:

  • pixelType The pixel type of the image to save.
  • width The number of pixels in a row of the image to save.
  • height The number of rows of the image to save.
  • paddingX The number of extra data bytes at the end of each row.
  • orientation The vertical orientation of the image data in the video file.

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

Error Safety:

Does not throw C++ exceptions.

function CanAddWithoutConversion#

virtual bool CanAddWithoutConversion(
    const Pylon::IImage & image
)

Can be used to check whether the given image is added to the video file without prior conversion when Add() is called.

Parameters:

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

Error Safety:

Does not throw C++ exceptions.

function GetNodeMap#

virtual GenApi::INodeMap & GetNodeMap()

Provides access to all parameters via a nodemap.

Error Safety:

Does not throw C++ exceptions.

function IsSupported#

static bool IsSupported()

Checks if video writing is supported.

Return: Returns true if video writing is supported.

Error Safety:

Does not throw C++ exceptions.

Checks if all necessary dynamic libraries of the supplementary software package are installed and can be loaded. This does not check if the codec for the video can be used. This is checked in Open().

Protected Functions Documentation#

function GetLock#

CLock & GetLock()

Provides access to the lock used for synchronizing the access to the video writer.

Error Safety:

Does not throw C++ exceptions.

Public Attributes Documentation#

variable Bitrate#

Pylon::IIntegerEx & Bitrate;

Bit rate of the resulting compressed stream.

Visibility: Beginner

variable CompressionMode#

Pylon::IEnumParameterT< CompressionModeEnums > & CompressionMode;

Sets the compression mode.

Sets the compression mode. You can choose whether to keep the bit rate or the quality of the resulting video stream constant.

Visibility: Beginner

variable PlaybackFrameRate#

Pylon::IFloatEx & PlaybackFrameRate;

Frame rate (in Hertz) of the video to be recorded.

Visibility: Beginner

variable Quality#

Pylon::IFloatEx & Quality;

Quality of the resulting compressed stream.

Quality of the resulting compressed stream. The quality has a direct influence on the resulting bit rate. The optimal bit rate is calculated based on the input values height, width, and playback frame rate (WIDTH * HEIGHT * PLAYBACKFRAMERATE * 0.25). This is then normalized to the quality value range 1-100, where 100 corresponds to the optimum bit rate and 1 to the lowest bit rate.

Visibility: Beginner

variable ThreadCount#

Pylon::IIntegerEx & ThreadCount;

Number of threads used for recording the video.

Visibility: Expert

variable BytesWritten#

Pylon::IIntegerEx & BytesWritten;

Bytes written to file since starting the recording.

Visibility: Beginner

variable FrameCount#

Pylon::IIntegerEx & FrameCount;

Number of frames written since starting the recording.

Visibility: Beginner

variable Height#

Pylon::IIntegerEx & Height;

Height of the image (in pixels)

Visibility: Invisible

variable Width#

Pylon::IIntegerEx & Width;

Width of the image (in pixels)

Visibility: Invisible