ViSP  2.7.0
vpVideoWriter.h
1 /****************************************************************************
2  *
3  * $Id: vpImagePoint.h 2359 2009-11-24 15:09:25Z nmelchio $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Write videos and sequences of images.
36  *
37  * Authors:
38  * Nicolas Melchior
39  *
40  *****************************************************************************/
41 
47 #ifndef vpVideoWriter_H
48 #define vpVideoWriter_H
49 
50 #include <string>
51 
52 #include <visp/vpImageIo.h>
53 #include <visp/vpFFMPEG.h>
54 
133 class VISP_EXPORT vpVideoWriter
134 {
135  private:
136 #ifdef VISP_HAVE_FFMPEG
137  vpFFMPEG *ffmpeg;
140  CodecID codec;
142  unsigned int bit_rate;
143 #endif
144  typedef enum
146  {
147  FORMAT_PGM,
148  FORMAT_PPM,
149  FORMAT_JPEG,
150  FORMAT_PNG,
151  FORMAT_AVI,
152  FORMAT_MPEG,
153  FORMAT_MOV,
154  FORMAT_UNKNOWN
155  } vpVideoFormatType;
156 
158  vpVideoFormatType formatType;
159 
161  char fileName[FILENAME_MAX];
162 
164  bool initFileName;
165 
167  bool isOpen;
168 
170  unsigned int frameCount;
171 
173  unsigned int firstFrame;
174 
176  unsigned int width;
177  unsigned int height;
178 
179  public:
180  vpVideoWriter();
181  ~vpVideoWriter();
182 
183  void close();
184 
190  inline unsigned int getCurrentFrameIndex() const {return frameCount;}
191 
192  void open (vpImage< vpRGBa > &I);
193  void open (vpImage< unsigned char > &I);
199  inline void resetFrameCounter() {frameCount = firstFrame;}
200 
201  void saveFrame (vpImage< vpRGBa > &I);
202  void saveFrame (vpImage< unsigned char > &I);
203 
204 #ifdef VISP_HAVE_FFMPEG
205 
212  inline void setBitRate(const unsigned int bit_rate) {this->bit_rate = bit_rate;}
213 
223  inline void setCodec(const CodecID codec) {this->codec = codec;}
224 #endif
225 
226  void setFileName(const char *filename);
227  void setFileName(const std::string &filename);
233  inline void setFirstFrameIndex(const unsigned int firstFrame) {this->firstFrame = firstFrame;}
234 
235  private:
236  vpVideoFormatType getFormat(const char *filename);
237  static std::string getExtension(const std::string &filename);
238 };
239 
240 #endif
void setCodec(const CodecID codec)
void setBitRate(const unsigned int bit_rate)
unsigned int getCurrentFrameIndex() const
void resetFrameCounter()
Class that enables to write easily a video file or a sequence of images.
This class interfaces the FFmpeg library to enable the reading of video files.
Definition: vpFFMPEG.h:154
void setFirstFrameIndex(const unsigned int firstFrame)