ViSP
2.10.0
|
#include <vpFFMPEG.h>
Public Types | |
enum | vpFFMPEGColorType { COLORED, GRAY_SCALED } |
Public Member Functions | |
vpFFMPEG () | |
~vpFFMPEG () | |
bool | acquire (vpImage< vpRGBa > &I) |
bool | acquire (vpImage< unsigned char > &I) |
void | closeStream () |
bool | endWrite () |
bool | getFrame (vpImage< vpRGBa > &I, unsigned int frameNumber) |
bool | getFrame (vpImage< unsigned char > &I, unsigned int frameNumber) |
unsigned long | getFrameNumber () const |
double | getFramerate () const |
int | getHeight () const |
int | getWidth () const |
bool | initStream () |
bool | openEncoder (const char *filename, unsigned int width, unsigned int height, AVCodecID codec=AV_CODEC_ID_MPEG1VIDEO) |
bool | openStream (const char *filename, vpFFMPEGColorType color_type) |
bool | saveFrame (vpImage< vpRGBa > &I) |
bool | saveFrame (vpImage< unsigned char > &I) |
void | setBitRate (const unsigned int rate) |
void | setFramerate (const int framerate) |
This class interfaces the FFmpeg library to enable video stream reading or writing.
Here an example which explains how to use the class to read a video stream.
If you want to open the video as a gray scaled video, you can use the following example.
Definition at line 149 of file vpFFMPEG.h.
Enumerator | |
---|---|
COLORED | |
GRAY_SCALED |
Definition at line 152 of file vpFFMPEG.h.
vpFFMPEG::vpFFMPEG | ( | ) |
Basic constructor.
Definition at line 67 of file vpFFMPEG.cpp.
vpFFMPEG::~vpFFMPEG | ( | ) |
Gets the Next frame in the video.
I | : The vpImage used to stored the video's frame. |
Definition at line 348 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
Referenced by vpVideoReader::acquire().
bool vpFFMPEG::acquire | ( | vpImage< unsigned char > & | I | ) |
Gets the Next frame in the video.
I | : The vpImage used to stored the video's frame. |
Definition at line 447 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
void vpFFMPEG::closeStream | ( | ) |
Deallocates all the FFMPEG parameters.
Definition at line 601 of file vpFFMPEG.cpp.
References COLORED, endWrite(), and GRAY_SCALED.
Referenced by ~vpFFMPEG().
bool vpFFMPEG::endWrite | ( | ) |
Ends the writing of the video and close the file.
Definition at line 838 of file vpFFMPEG.cpp.
References vpTRACE.
Referenced by vpVideoWriter::close(), and closeStream().
Gets the th frame from the video and stores it in the image .
I | : The vpImage used to stored the video's frame. |
frame | : The index of the frame which has to be read. |
Definition at line 294 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
Referenced by vpVideoReader::getFrame().
bool vpFFMPEG::getFrame | ( | vpImage< unsigned char > & | I, |
unsigned int | frame | ||
) |
Gets the th frame from the video and stores it in the image .
I | : The vpImage used to stored the video's frame. |
frame | : The index of the frame which has to be read. |
Definition at line 393 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
|
inline |
Gets the video's frame number.
Definition at line 216 of file vpFFMPEG.h.
|
inline |
Return the framerate used to encode the video. The video stream need to be opened before calling this function.
vpException::ioError | : If the video stream was not opened priviously. |
Definition at line 223 of file vpFFMPEG.h.
References vpException::ioError.
Referenced by vpVideoReader::getFramerate().
|
inline |
Gets the video's height.
Definition at line 233 of file vpFFMPEG.h.
|
inline |
Gets the video's width.
Definition at line 239 of file vpFFMPEG.h.
bool vpFFMPEG::initStream | ( | ) |
This method initializes the conversion parameters.
It browses the video and lists all the frame. It sets the number of frame in the video.
Definition at line 235 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
Referenced by vpVideoReader::open().
bool vpFFMPEG::openEncoder | ( | const char * | filename, |
unsigned int | w, | ||
unsigned int | h, | ||
AVCodecID | codec = AV_CODEC_ID_MPEG1VIDEO |
||
) |
Allocates and initializes the parameters depending on the video to write.
filename | : Path to the video which has to be writen. |
w,h | : Width and height of the image which will be saved. |
codec | : Type of codec used to encode the video. |
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 672 of file vpFFMPEG.cpp.
Referenced by vpVideoWriter::open().
bool vpFFMPEG::openStream | ( | const char * | filename, |
vpFFMPEGColorType | colortype | ||
) |
Allocates and initializes the parameters depending on the video and the desired color type. One the stream is opened, it is possible to get the video encoding framerate getFramerate(), and the dimension of the images using getWidth() and getHeight().
filename | : Path to the video which has to be read. |
colortype | : Desired color map used to open the video. The parameter can take two values : COLORED and GRAY_SCALED. |
Definition at line 99 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
Referenced by vpVideoReader::open().
Saves the image I as frame of the video.
I | : the image to save. |
Definition at line 756 of file vpFFMPEG.cpp.
References vpTRACE.
Referenced by vpVideoWriter::saveFrame().
bool vpFFMPEG::saveFrame | ( | vpImage< unsigned char > & | I | ) |
Saves the image I as frame of the video.
I | : the image to save. |
Definition at line 798 of file vpFFMPEG.cpp.
References vpTRACE.
|
inline |
Sets the bit rate of the video when encoding.
rate | : the expected bit rate. |
Definition at line 257 of file vpFFMPEG.h.
Referenced by vpVideoWriter::open().
|
inline |
Sets the framerate of the video when encoding.
framerate | : the expected framerate. |
Definition at line 263 of file vpFFMPEG.h.
Referenced by vpVideoWriter::open().