ViSP
2.9.0
|
#include <vpVideoWriter.h>
Public Member Functions | |
vpVideoWriter () | |
~vpVideoWriter () | |
void | close () |
unsigned int | getCurrentFrameIndex () const |
void | open (vpImage< vpRGBa > &I) |
void | open (vpImage< unsigned char > &I) |
void | resetFrameCounter () |
void | saveFrame (vpImage< vpRGBa > &I) |
void | saveFrame (vpImage< unsigned char > &I) |
void | setBitRate (const unsigned int bitrate) |
void | setCodec (const AVCodecID codec_id) |
void | setFileName (const char *filename) |
void | setFileName (const std::string &filename) |
void | setFirstFrameIndex (const unsigned int first_frame) |
void | setFramerate (const int frame_rate) |
Class that enables to write easily a video file or a sequence of images.
The following example shows how this class is really easy to use. It enable to write an image sequence. The images are stored in the folder "./image" and are named "image0000.jpeg", "image0001.jpeg", "image0002.jpeg", ...
The other following example explains how to use the class to write directly an mpeg file.
Definition at line 135 of file vpVideoWriter.h.
vpVideoWriter::vpVideoWriter | ( | ) |
Basic constructor.
Definition at line 54 of file vpVideoWriter.cpp.
vpVideoWriter::~vpVideoWriter | ( | ) |
Basic destructor.
Definition at line 90 of file vpVideoWriter.cpp.
void vpVideoWriter::close | ( | ) |
Deallocates parameters use to write the video or the image sequence.
Definition at line 316 of file vpVideoWriter.cpp.
References vpFFMPEG::endWrite(), vpException::notInitialized, and vpERROR_TRACE.
|
inline |
Gets the current frame index.
Definition at line 197 of file vpVideoWriter.h.
Sets all the parameters needed to write the video or the image sequence.
I | : One image with the right dimensions. |
Definition at line 143 of file vpVideoWriter.cpp.
References vpException::fatalError, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpException::ioError, vpImageException::noFileNameError, vpFFMPEG::openEncoder(), vpFFMPEG::setBitRate(), vpFFMPEG::setFramerate(), and vpERROR_TRACE.
void vpVideoWriter::open | ( | vpImage< unsigned char > & | I | ) |
Sets all the parameters needed to write the video or the image sequence.
I | : One image with the right dimensions. |
Definition at line 192 of file vpVideoWriter.cpp.
References vpException::fatalError, vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpException::ioError, vpImageException::noFileNameError, vpFFMPEG::openEncoder(), vpFFMPEG::setBitRate(), vpFFMPEG::setFramerate(), and vpERROR_TRACE.
|
inline |
Reset the frame counter and sets it to the first image index.
By default the first frame index is set to 0.
Definition at line 206 of file vpVideoWriter.h.
Saves the image as a frame of the video or as an image belonging to the image sequence.
Each time this method is used, the frame counter is incremented and thus the file name change for the case of an image sequence.
I | : The image which has to be saved |
Definition at line 243 of file vpVideoWriter.cpp.
References vpException::notInitialized, vpFFMPEG::saveFrame(), vpERROR_TRACE, and vpImageIo::write().
void vpVideoWriter::saveFrame | ( | vpImage< unsigned char > & | I | ) |
Saves the image as a frame of the video or as an image belonging to the image sequence.
Each time this method is used, the frame counter is incremented and thus the file name change for the case of an image sequence.
I | : The image which has to be saved |
Definition at line 282 of file vpVideoWriter.cpp.
References vpException::notInitialized, vpFFMPEG::saveFrame(), vpERROR_TRACE, and vpImageIo::write().
|
inline |
Sets the bit rate of the video when encoding.
bitrate | : the expected bit rate. |
By default the bit rate is set to 500 000.
Definition at line 219 of file vpVideoWriter.h.
|
inline |
Sets the codec used to encode the video.
codec_id | : the expected codec. |
By default codec is set to AV_CODEC_ID_MPEG1VIDEO. But if installed, you can use one of the AVCodecID proposed by ffmpeg such as : AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG2VIDEO_XVMC, AV_CODEC_ID_MPEG4, AV_CODEC_ID_H264, ... (More AVCodecID can be found in the ffmpeg documentation).
Of course to use the codec it must be installed on your computer.
Definition at line 235 of file vpVideoWriter.h.
void vpVideoWriter::setFileName | ( | const char * | filename | ) |
It enables to set the path and the name of the files which will be saved.
If you want to write a sequence of images, corresponds to the path followed by the image name template. For exemple, if you want to write different images named image0001.jpeg, image0002.jpg, ... and located in the folder /local/image, will be "/local/image/image%04d.jpg".
filename | : filename template of an image sequence. |
Definition at line 106 of file vpVideoWriter.cpp.
References vpException::memoryAllocationError, vpImageException::noFileNameError, and vpERROR_TRACE.
Referenced by setFileName().
void vpVideoWriter::setFileName | ( | const std::string & | filename | ) |
It enables to set the path and the name of the files which will be saved.
If you want to write a sequence of images, corresponds to the path followed by the image name template. For exemple, if you want to write different images named image0001.jpeg, image0002.jpg, ... and located in the folder /local/image, will be "/local/image/image%04d.jpg".
filename | : filename template of an image sequence. |
Definition at line 133 of file vpVideoWriter.cpp.
References setFileName().
|
inline |
Enables to set the first frame index.
first_frame | : The first frame index. |
Definition at line 246 of file vpVideoWriter.h.
|
inline |
Sets the framerate in Hz of the video when encoding.
frame_rate | : the expected framerate. |
By default the framerate is set to 25Hz.
Definition at line 255 of file vpVideoWriter.h.