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);
127 if (formatType == FORMAT_PGM ||
128 formatType == FORMAT_PPM ||
129 formatType == FORMAT_JPEG ||
130 formatType == FORMAT_PNG)
135 #ifdef VISP_HAVE_FFMPEG
136 else if (formatType == FORMAT_AVI ||
137 formatType == FORMAT_MPEG ||
138 formatType == FORMAT_MOV)
147 else if (formatType == FORMAT_AVI ||
148 formatType == FORMAT_MPEG ||
149 formatType == FORMAT_MOV)
151 vpERROR_TRACE(
"To write video files the FFmpeg library has to be installed");
156 frameCount = firstFrame;
175 if (formatType == FORMAT_PGM ||
176 formatType == FORMAT_PPM ||
177 formatType == FORMAT_JPEG ||
178 formatType == FORMAT_PNG)
183 #ifdef VISP_HAVE_FFMPEG
184 else if (formatType == FORMAT_AVI ||
185 formatType == FORMAT_MPEG ||
186 formatType == FORMAT_MOV)
195 else if (formatType == FORMAT_AVI ||
196 formatType == FORMAT_MPEG ||
197 formatType == FORMAT_MOV)
199 vpERROR_TRACE(
"To write video files the FFmpeg library has to be installed");
204 frameCount = firstFrame;
221 vpERROR_TRACE(
"The video has to be open first with the open method");
226 if (formatType == FORMAT_PGM ||
227 formatType == FORMAT_PPM ||
228 formatType == FORMAT_JPEG ||
229 formatType == FORMAT_PNG)
231 char name[FILENAME_MAX];
233 sprintf(name,fileName,frameCount);
238 #ifdef VISP_HAVE_FFMPEG
260 vpERROR_TRACE(
"The video has to be open first with the open method");
264 if (formatType == FORMAT_PGM ||
265 formatType == FORMAT_PPM ||
266 formatType == FORMAT_JPEG ||
267 formatType == FORMAT_PNG)
269 char name[FILENAME_MAX];
271 sprintf(name,fileName,frameCount);
276 #ifdef VISP_HAVE_FFMPEG
294 vpERROR_TRACE(
"The video has to be open first with the open method");
297 #ifdef VISP_HAVE_FFMPEG
311 vpVideoWriter::vpVideoFormatType
312 vpVideoWriter::getFormat(
const char *filename)
314 std::string sfilename(filename);
316 std::string ext = vpVideoWriter::getExtension(sfilename);
318 if (ext.compare(
".PGM") == 0)
320 else if (ext.compare(
".pgm") == 0)
322 else if (ext.compare(
".PPM") == 0)
324 else if (ext.compare(
".ppm") == 0)
326 else if (ext.compare(
".JPG") == 0)
328 else if (ext.compare(
".jpg") == 0)
330 else if (ext.compare(
".JPEG") == 0)
332 else if (ext.compare(
".jpeg") == 0)
334 else if (ext.compare(
".PNG") == 0)
336 else if (ext.compare(
".png") == 0)
338 else if (ext.compare(
".AVI") == 0)
340 else if (ext.compare(
".avi") == 0)
342 else if (ext.compare(
".MPEG") == 0)
344 else if (ext.compare(
".mpeg") == 0)
346 else if (ext.compare(
".MPG") == 0)
348 else if (ext.compare(
".mpg") == 0)
350 else if (ext.compare(
".MOV") == 0)
352 else if (ext.compare(
".mov") == 0)
355 return FORMAT_UNKNOWN;
359 std::string vpVideoWriter::getExtension(
const std::string &filename)
362 size_t dot = filename.find_last_of(
".");
363 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 ViSP classes.
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