ViSP  2.9.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 - 2014 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 
135 class VISP_EXPORT vpVideoWriter
136 {
137  private:
138 #ifdef VISP_HAVE_FFMPEG
139  vpFFMPEG *ffmpeg;
142 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,51,110) // libavcodec 54.51.100
143  CodecID codec;
144 #else
145  AVCodecID codec;
146 #endif
147  unsigned int bit_rate;
149  int framerate;
150 #endif
151  typedef enum
153  {
154  FORMAT_PGM,
155  FORMAT_PPM,
156  FORMAT_JPEG,
157  FORMAT_PNG,
158  FORMAT_AVI,
159  FORMAT_MPEG,
160  FORMAT_MOV,
161  FORMAT_UNKNOWN
162  } vpVideoFormatType;
163 
165  vpVideoFormatType formatType;
166 
168  char fileName[FILENAME_MAX];
169 
171  bool initFileName;
172 
174  bool isOpen;
175 
177  unsigned int frameCount;
178 
180  unsigned int firstFrame;
181 
183  unsigned int width;
184  unsigned int height;
185 
186  public:
187  vpVideoWriter();
188  ~vpVideoWriter();
189 
190  void close();
191 
197  inline unsigned int getCurrentFrameIndex() const {return frameCount;}
198 
199  void open (vpImage< vpRGBa > &I);
200  void open (vpImage< unsigned char > &I);
206  inline void resetFrameCounter() {frameCount = firstFrame;}
207 
208  void saveFrame (vpImage< vpRGBa > &I);
209  void saveFrame (vpImage< unsigned char > &I);
210 
211 #ifdef VISP_HAVE_FFMPEG
212 
219  inline void setBitRate(const unsigned int bitrate) {this->bit_rate = bitrate;}
220 
232 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54,51,110) // libavcodec 54.51.100
233  inline void setCodec(const CodecID codec_id) {this->codec = codec_id;}
234 #else
235  inline void setCodec(const AVCodecID codec_id) {this->codec = codec_id;}
236 #endif
237 #endif
238 
239  void setFileName(const char *filename);
240  void setFileName(const std::string &filename);
246  inline void setFirstFrameIndex(const unsigned int first_frame) {this->firstFrame = first_frame;}
247 #ifdef VISP_HAVE_FFMPEG
248 
255  inline void setFramerate(const int frame_rate) {
256  this->framerate = frame_rate;
257  }
258 #endif
259 
260  private:
261  vpVideoFormatType getFormat(const char *filename);
262  static std::string getExtension(const std::string &filename);
263 };
264 
265 #endif
void setBitRate(const unsigned int bitrate)
unsigned int getCurrentFrameIndex() const
void setFirstFrameIndex(const unsigned int first_frame)
void setCodec(const AVCodecID codec_id)
void resetFrameCounter()
Class that enables to write easily a video file or a sequence of images.
This class interfaces the FFmpeg library to enable video stream reading or writing.
Definition: vpFFMPEG.h:149
void setFramerate(const int frame_rate)