![]() |
ViSP
2.6.2
|
#include <vpFFMPEG.h>
Public Types | |
enum | vpFFMPEGColorType { COLORED, GRAY_SCALED } |
Public Member Functions | |
vpFFMPEG () | |
~vpFFMPEG () | |
int | getWidth () const |
int | getHeight () const |
unsigned long | getFrameNumber () const |
void | setBitRate (const unsigned int bit_rate) |
bool | openStream (const char *filename, vpFFMPEGColorType color_type) |
bool | initStream () |
void | closeStream () |
bool | acquire (vpImage< vpRGBa > &I) |
bool | acquire (vpImage< unsigned char > &I) |
bool | getFrame (vpImage< vpRGBa > &I, unsigned int frameNumber) |
bool | getFrame (vpImage< unsigned char > &I, unsigned int frameNumber) |
bool | openEncoder (const char *filename, unsigned int width, unsigned int height, CodecID codec=CODEC_ID_MPEG1VIDEO) |
bool | saveFrame (vpImage< vpRGBa > &I) |
bool | saveFrame (vpImage< unsigned char > &I) |
bool | endWrite () |
This class interfaces the FFmpeg library to enable the reading of video files.
Here an example which explains how to use the class.
If you want to open the video as a gray scaled video, you can use the following example.
Definition at line 154 of file vpFFMPEG.h.
Enumerator | |
---|---|
COLORED | |
GRAY_SCALED |
Definition at line 157 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 328 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 425 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
void vpFFMPEG::closeStream | ( | ) |
Deallocates all the FFMPEG parameters.
Definition at line 578 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 763 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 275 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 372 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
|
inline |
Gets the video's frame number.
Definition at line 224 of file vpFFMPEG.h.
|
inline |
Gets the video's height.
Definition at line 217 of file vpFFMPEG.h.
|
inline |
Gets the video's width.
Definition at line 210 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 217 of file vpFFMPEG.cpp.
References COLORED, GRAY_SCALED, and vpTRACE.
Referenced by vpVideoReader::open().
bool vpFFMPEG::openEncoder | ( | const char * | filename, |
unsigned int | width, | ||
unsigned int | height, | ||
CodecID | codec = CODEC_ID_MPEG1VIDEO |
||
) |
Allocates and initializes the parameters depending on the video to write.
filename | : Path to the video which has to be writen. |
width | : Width of the image which will be saved. |
height | : Height of the image which will be saved. |
codec | : Type of codec used to encode the video. |
By default codec is set to CODEC_ID_MPEG1VIDEO. But you can use one of the CodecID proposed by ffmpeg such as : CODEC_ID_MPEG2VIDEO, CODEC_ID_MPEG2VIDEO_XVMC, CODEC_ID_MPEG4, CODEC_ID_H264, ... (More CodecID can be found in the ffmpeg documentation).
Of course to use the codec it must be installed on your computer.
Definition at line 642 of file vpFFMPEG.cpp.
Referenced by vpVideoWriter::open().
bool vpFFMPEG::openStream | ( | const char * | filename, |
vpFFMPEGColorType | color_type | ||
) |
Allocates and initializes the parameters depending on the video and the desired color type.
filename | : Path to the video which has to be read. |
color_type | : Desired color map used to open the video. The parameter can take two values : COLORED and GRAY_SCALED. |
Definition at line 101 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 718 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 742 of file vpFFMPEG.cpp.
References vpTRACE.
|
inline |
Sets the bit rate of the video when writing.
bit_rate | : the expected bit rate. |
Definition at line 231 of file vpFFMPEG.h.
Referenced by vpVideoWriter::open().