Ignition Common

API Reference

3.6.1
VideoEncoder Class Reference

The VideoEncoder class supports encoding a series of images to a video format, and then writing the video to disk. More...

#include <VideoEncoder.hh>

Public Member Functions

 VideoEncoder ()
 Constructor. More...
 
virtual ~VideoEncoder ()
 Destructor. More...
 
bool AddFrame (const unsigned char *_frame, const unsigned int _width, const unsigned int _height)
 Add a single frame to be encoded. More...
 
bool AddFrame (const unsigned char *_frame, const unsigned int _width, const unsigned int _height, const std::chrono::steady_clock::time_point &_timestamp)
 Add a single timestamped frame to be encoded. More...
 
unsigned int BitRate () const
 Get the bit rate. More...
 
std::string Format () const
 Get the encoding format. More...
 
bool IsEncoding () const
 True if the enoder has been started, false otherwise. More...
 
void Reset ()
 Reset to default video properties and clean up allocated memory. This will also delete any temporary files. More...
 
bool SaveToFile (const std::string &_filename)
 Write the video to disk param[in] _filename File in which to save the encoded data. More...
 
bool Start (const std::string &_format="mp4", const std::string &_filename="", const unsigned int _width=1280, const unsigned int _height=720, const unsigned int _fps=25, const unsigned int _bitRate=0)
 Start the encoder. This should be called once. Add new frames to the video using the AddFrame function. Use SaveToFile when the video is complete. More...
 
bool Stop ()
 Stop the encoder. The SaveToFile function also calls this function. More...
 

Detailed Description

The VideoEncoder class supports encoding a series of images to a video format, and then writing the video to disk.

Constructor & Destructor Documentation

◆ VideoEncoder()

Constructor.

◆ ~VideoEncoder()

virtual ~VideoEncoder ( )
virtual

Destructor.

Member Function Documentation

◆ AddFrame() [1/2]

bool AddFrame ( const unsigned char *  _frame,
const unsigned int  _width,
const unsigned int  _height 
)

Add a single frame to be encoded.

Parameters
[in]_frameImage buffer to be encoded
[in]_widthInput frame width
[in]_heightInput frame height
Returns
True on success

◆ AddFrame() [2/2]

bool AddFrame ( const unsigned char *  _frame,
const unsigned int  _width,
const unsigned int  _height,
const std::chrono::steady_clock::time_point &  _timestamp 
)

Add a single timestamped frame to be encoded.

Parameters
[in]_frameImage buffer to be encoded
[in]_widthInput frame width
[in]_heightInput frame height
[in]_timestampTimestamp of the image frame
Returns
True on success.

◆ BitRate()

unsigned int BitRate ( ) const

Get the bit rate.

Returns
Bit rate

◆ Format()

std::string Format ( ) const

Get the encoding format.

Returns
Encoding format

◆ IsEncoding()

bool IsEncoding ( ) const

True if the enoder has been started, false otherwise.

Returns
True if Start has been called.

◆ Reset()

void Reset ( )

Reset to default video properties and clean up allocated memory. This will also delete any temporary files.

◆ SaveToFile()

bool SaveToFile ( const std::string _filename)

Write the video to disk param[in] _filename File in which to save the encoded data.

Returns
True on success.

◆ Start()

bool Start ( const std::string _format = "mp4",
const std::string _filename = "",
const unsigned int  _width = 1280,
const unsigned int  _height = 720,
const unsigned int  _fps = 25,
const unsigned int  _bitRate = 0 
)

Start the encoder. This should be called once. Add new frames to the video using the AddFrame function. Use SaveToFile when the video is complete.

Parameters
[in]_widthWidth in pixels of the output video.
[in]_heightHeight in pixels of the output video.
[in]_formatString that represents the video type. Supported types include: "avi", "ogv", mp4", "v4l2". If using "v4l2", you must also specify a _filename.
[in]_bitRateBit rate to encode the video. A value of zero will cause this function to automatically compute a bitrate.
[in]_filenameName of the file that stores the video while it is being created. This is a temporary file when recording to disk, or a video4linux loopback device like /dev/video0 when the _format is "v4l2". If blank, a default temporary file is used. However, the "v4l2" _format must be accompanied with a video loopback device filename.
Returns
True on success

◆ Stop()

bool Stop ( )

Stop the encoder. The SaveToFile function also calls this function.

Returns
True on success.

The documentation for this class was generated from the following file: