48 #include <visp/vpDebug.h>
49 #include <visp/vpVideoWriter.h>
60 #ifdef VISP_HAVE_FFMPEG
62 codec = CODEC_ID_MPEG1VIDEO;
73 #ifdef VISP_HAVE_FFMPEG
95 strcpy(this->fileName,filename);
97 formatType = getFormat(fileName);
116 if (formatType == FORMAT_PGM ||
117 formatType == FORMAT_PPM ||
118 formatType == FORMAT_JPEG ||
119 formatType == FORMAT_PNG)
124 #ifdef VISP_HAVE_FFMPEG
125 else if (formatType == FORMAT_AVI ||
126 formatType == FORMAT_MPEG ||
127 formatType == FORMAT_MOV)
136 else if (formatType == FORMAT_AVI ||
137 formatType == FORMAT_MPEG ||
138 formatType == FORMAT_MOV)
140 vpERROR_TRACE(
"To write video files the FFmpeg library has to be installed");
145 frameCount = firstFrame;
164 if (formatType == FORMAT_PGM ||
165 formatType == FORMAT_PPM ||
166 formatType == FORMAT_JPEG ||
167 formatType == FORMAT_PNG)
172 #ifdef VISP_HAVE_FFMPEG
173 else if (formatType == FORMAT_AVI ||
174 formatType == FORMAT_MPEG ||
175 formatType == FORMAT_MOV)
184 else if (formatType == FORMAT_AVI ||
185 formatType == FORMAT_MPEG ||
186 formatType == FORMAT_MOV)
188 vpERROR_TRACE(
"To write video files the FFmpeg library has to be installed");
193 frameCount = firstFrame;
210 vpERROR_TRACE(
"The video has to be open first with the open method");
215 if (formatType == FORMAT_PGM ||
216 formatType == FORMAT_PPM ||
217 formatType == FORMAT_JPEG ||
218 formatType == FORMAT_PNG)
220 char name[FILENAME_MAX];
222 sprintf(name,fileName,frameCount);
227 #ifdef VISP_HAVE_FFMPEG
249 vpERROR_TRACE(
"The video has to be open first with the open method");
253 if (formatType == FORMAT_PGM ||
254 formatType == FORMAT_PPM ||
255 formatType == FORMAT_JPEG ||
256 formatType == FORMAT_PNG)
258 char name[FILENAME_MAX];
260 sprintf(name,fileName,frameCount);
265 #ifdef VISP_HAVE_FFMPEG
283 vpERROR_TRACE(
"The video has to be open first with the open method");
286 #ifdef VISP_HAVE_FFMPEG
300 vpVideoWriter::vpVideoFormatType
301 vpVideoWriter::getFormat(
const char *filename)
303 std::string sfilename(filename);
305 std::string ext = vpVideoWriter::getExtension(sfilename);
307 if (ext.compare(
".PGM") == 0)
309 else if (ext.compare(
".pgm") == 0)
311 else if (ext.compare(
".PPM") == 0)
313 else if (ext.compare(
".ppm") == 0)
315 else if (ext.compare(
".JPG") == 0)
317 else if (ext.compare(
".jpg") == 0)
319 else if (ext.compare(
".JPEG") == 0)
321 else if (ext.compare(
".jpeg") == 0)
323 else if (ext.compare(
".PNG") == 0)
325 else if (ext.compare(
".png") == 0)
327 else if (ext.compare(
".AVI") == 0)
329 else if (ext.compare(
".avi") == 0)
331 else if (ext.compare(
".MPEG") == 0)
333 else if (ext.compare(
".mpeg") == 0)
335 else if (ext.compare(
".MPG") == 0)
337 else if (ext.compare(
".mpg") == 0)
339 else if (ext.compare(
".MOV") == 0)
341 else if (ext.compare(
".mov") == 0)
344 return FORMAT_UNKNOWN;
348 std::string vpVideoWriter::getExtension(
const std::string &filename)
351 size_t dot = filename.find_last_of(
".");
352 std::string ext = filename.substr(dot, filename.size()-1);
static void write(const vpImage< unsigned char > &I, const char *filename)
unsigned int getWidth() const
void setBitRate(const unsigned int bit_rate)
bool saveFrame(vpImage< vpRGBa > &I)
Error that can be emited by the vpImage class and its derivates.
bool openEncoder(const char *filename, unsigned int width, unsigned int height, CodecID codec=CODEC_ID_MPEG1VIDEO)
This class interfaces the FFmpeg library to enable the reading of video files.
void saveFrame(vpImage< vpRGBa > &I)
void open(vpImage< vpRGBa > &I)
void setFileName(const char *filename)
unsigned int getHeight() const