ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QVideoEncoder.h
Go to the documentation of this file.
1 // Inspired from QTFFmpegWrapper (Daniel Roggen) and the 'muxing.c' example in
2 // FFmpeg doc/examples
3 #ifndef Q_VIDEO_ENCODE_HEADER
4 #define Q_VIDEO_ENCODE_HEADER
5 
6 // Qt
7 #include <QImage>
8 
9 // FFmpeg variables (we don't want to pollute the client project with FFmpeg
10 // includes!)
11 struct FFmpegStuffEnc;
12 
15 public:
17 
24  QVideoEncoder(QString filename,
25  int width,
26  int height,
27  unsigned bitrate,
28  int gop = 12,
29  int fps = 25);
30 
31  virtual ~QVideoEncoder();
32 
34 
40  bool open(QString formatShortName, QStringList& errors);
41 
43  inline bool isOpen() const { return m_isOpen; }
44 
46  virtual bool encodeImage(const QImage& image,
47  int frameIndex,
48  QString* errorString = nullptr);
49 
51  virtual bool close();
52 
54  struct OutputFormat {
55  QString shortName;
56  QString longName;
57  QString extensions;
58  };
59 
61  static bool GetSupportedOutputFormats(std::vector<OutputFormat>& formats,
62  bool ignoreIfNoFileExtension = true);
63 
64 protected:
65  // stream descriptor
66  QString m_filename;
67  int m_width;
68  int m_height;
69  unsigned m_bitrate;
70  int m_gop;
71  int m_fps;
72  bool m_isOpen;
73 
76 
78  bool isSizeValid();
79 
80  // Alloc/free a frame
81  bool initFrame();
82  void freeFrame();
83 
85 
90  bool convertImage_sws(const QImage& image, QString* errorString = nullptr);
91 };
92 
93 #endif // Q_VIDEO_ENCODE_HEADER
std::string filename
std::shared_ptr< core::Tensor > image
int width
int height
Video encoder based on FFmpeg.
Definition: QVideoEncoder.h:14
virtual bool encodeImage(const QImage &image, int frameIndex, QString *errorString=nullptr)
Adds an image to the stream.
bool isSizeValid()
Returns whether the image size is valid.
virtual bool close()
Closes the file.
bool convertImage_sws(const QImage &image, QString *errorString=nullptr)
Convert the QImage to the internal YUV format.
bool open(QString formatShortName, QStringList &errors)
Creates an (empty) video/anmiation file.
virtual ~QVideoEncoder()
bool isOpen() const
Returns whether the file is opened or not.
Definition: QVideoEncoder.h:43
static bool GetSupportedOutputFormats(std::vector< OutputFormat > &formats, bool ignoreIfNoFileExtension=true)
Returns the list of supported output formats.
FFmpegStuffEnc * m_ff
FFmpeg variables.
Definition: QVideoEncoder.h:75
QString m_filename
Definition: QVideoEncoder.h:66
QVideoEncoder(QString filename, int width, int height, unsigned bitrate, int gop=12, int fps=25)
Default constructor.
unsigned m_bitrate
Definition: QVideoEncoder.h:69