# opentl::output::VideoWriter Class Reference

List of all members.

## Public Types
enum | Codec { CODEC_0_INVALID, CODEC_APPLE_VIDEO, CODEC_CINEPAK, CODEC_DIVX, CODEC_MPEG_4 = CODEC_DIVX, CODEC_FLV_1, CODEC_H_261, CODEC_H_263, CODEC_U_263 = CODEC_H_263, CODEC_H_263_I, CODEC_I_263 = CODEC_H_263_I, CODEC_H_263_P, CODEC_H_264, CODEC_INDEO_4, CODEC_INDEO_5, CODEC_JPEGLS, CODEC_JPEG_2000, CODEC_MJPG, CODEC_MPEG_1, CODEC_PIM1 = CODEC_MPEG_1, CODEC_MPEG_2, CODEC_MPEG_2_XVMC, CODEC_MPEG_4_1, CODEC_MPEG_4_2, CODEC_MPEG_4_3, CODEC_DIV_3 = CODEC_MPEG_4_3, CODEC_RAWVIDEO, CODEC_RLE, CODEC_RV_10, CODEC_RV_20, CODEC_UNCOMPR_YUV, CODEC_IYUV = CODEC_UNCOMPR_YUV, CODEC_WMV_1, CODEC_WMV_2, CODEC_WMV_3, CODEC_XVID, CODECS_NUM }
## Public Member Functions
bool | init (const std::string &filename, int width, int height, double fps, Codec codec, ColorMode colorMode=VideoWriter::COLOR)
void | release ()
| VideoWriter ()
void | writeFrame (const opentl::core::cvdata::Image &img)
| ~VideoWriter (void)
## Static Public Member Functions
static const char * | codecFileExtension (int codecID)
static const char * | codecName (int codecID)

## Detailed Description

Facade class to encapsulate writing video files provides common interface for writing video in different formats and with different codecs on different OSs

## Member Enumeration Documentation

enum opentl::output::VideoWriter::Codec

Enumerator:

  CODEC_0_INVALID |
  CODEC_APPLE_VIDEO |
  CODEC_CINEPAK |
  CODEC_DIVX |
  CODEC_MPEG_4 |
  CODEC_FLV_1 |
  CODEC_H_261 |
  CODEC_H_263 |
  CODEC_U_263 |
  CODEC_H_263_I |
  CODEC_I_263 |
  CODEC_H_263_P |
  CODEC_H_264 |
  CODEC_INDEO_4 |
  CODEC_INDEO_5 |
  CODEC_JPEGLS |
  CODEC_JPEG_2000 |
  CODEC_MJPG |
  CODEC_MPEG_1 |
  CODEC_PIM1 |
  CODEC_MPEG_2 |
  CODEC_MPEG_2_XVMC |
  CODEC_MPEG_4_1 |
  CODEC_MPEG_4_2 |
  CODEC_MPEG_4_3 |
  CODEC_DIV_3 |
  CODEC_RAWVIDEO |
  CODEC_RLE |
  CODEC_RV_10 |
  CODEC_RV_20 |
  CODEC_UNCOMPR_YUV |
  CODEC_IYUV |
  CODEC_WMV_1 |
  CODEC_WMV_2 |
  CODEC_WMV_3 |
  CODEC_XVID |
  CODECS_NUM |

enum opentl::output::VideoWriter::ColorMode

Enumerator:

  GRAYSCALE |
  COLOR |
  NUM_COLOR_MODES |

## Constructor & Destructor Documentation

opentl::output::VideoWriter::VideoWriter | ( |  | ) |

opentl::output::VideoWriter::~VideoWriter | ( | void |  | ) | `[inline]`

## Member Function Documentation

static const char* opentl::output::VideoWriter::codecFileExtension | ( | int | codecID | ) | `[inline, static]`

static const char* opentl::output::VideoWriter::codecName | ( | int | codecID | ) | `[inline, static]`

bool opentl::output::VideoWriter::init | ( | const std::string & | filename,
|  | int | width,
|  | int | height,
|  | double | fps,
|  | Codec | codec,
|  | ColorMode | colorMode = `VideoWriter::COLOR` |
| ) |  |  |

Initializes the video writer. Calling second time closes the existing video file and starts writing to another file

Parameters:

  | filename | Name of the file in which to write video
  | width | Width in pixels of the output video
  | height | Height in pixels of the output video
  | fps | Framerate (frames per second) in the output video
  | codec | Which codec to use. See `opentl::output::Videowriter::Codec` for supported codecs
  | colorMode | Which color mode to use. See `opentl::output::VideoWriter::ColorMode` for available color modes

Returns:
  If video writer has been successfully initialized

void opentl::output::VideoWriter::release | ( |  | ) |

Finishes writing to video file and cleans up. This method is called when a VideoWriter object is deleted.

void opentl::output::VideoWriter::writeFrame | ( | const opentl::core::cvdata::Image & | img | ) |

Writes an image as the next frame into the video file. `init` method must be called before starting writing frames. Image is automatically rescaled and converted to needed pixel format

Parameters:

  | img | Image to write as frame