QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
multimedia
qgsvideoexporter.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsvideoexporter.h
3
--------------------------
4
begin : November 2025
5
copyright : (C) 2025 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
#ifndef QGSVIDEOEXPORTER_H
16
#define QGSVIDEOEXPORTER_H
17
18
#include "qgis_core.h"
19
#include "
qgis_sip.h
"
20
21
#include <QObject>
22
#include <QPointer>
23
#include <QSize>
24
#include <QtMultimedia/QMediaFormat>
25
#include <QtMultimedia/QMediaRecorder>
26
27
class
QgsFeedback
;
28
class
QMediaCaptureSession;
29
class
QVideoFrameInput;
30
41
class
CORE_EXPORT
QgsVideoExporter
:
public
QObject
42
{
43
Q_OBJECT
44
45
public
:
49
static
bool
isAvailable
();
50
58
QgsVideoExporter
(
const
QString &filename, QSize
size
,
double
framesPerSecond
);
59
~QgsVideoExporter
()
override
;
60
68
void
setFeedback
(
QgsFeedback
*
feedback
);
69
75
QgsFeedback
*
feedback
();
76
82
double
framesPerSecond
()
const
{
return
mFramesPerSecond; }
83
89
qint64
frameDuration
()
const
{
return
mFrameDurationUs; }
90
94
QSize
size
()
const
{
return
mSize; }
95
105
void
setInputFiles(
const
QStringList &files );
106
118
void
setInputFilesByPattern(
const
QString &directory,
const
QString &pattern );
119
125
QStringList inputFiles()
const
;
126
127
#ifndef SIP_RUN
136
void
setFileFormat( QMediaFormat::FileFormat format );
137
143
QMediaFormat::FileFormat fileFormat()
const
;
144
153
void
setVideoCodec( QMediaFormat::VideoCodec codec );
154
160
QMediaFormat::VideoCodec videoCodec()
const
;
161
167
QMediaRecorder::Error error()
const
;
168
#endif
169
170
#ifdef SIP_PYQT6_RUN
171
180
void
setFileFormat( QMediaFormat::FileFormat format );
181
187
QMediaFormat::FileFormat fileFormat()
const
;
188
197
void
setVideoCodec( QMediaFormat::VideoCodec codec );
198
204
QMediaFormat::VideoCodec videoCodec()
const
;
205
211
QMediaRecorder::Error error()
const
;
212
#endif
213
219
QString errorString()
const
;
220
221
public
slots:
222
230
void
writeVideo()
SIP_THROW
(
QgsNotSupportedException
);
231
232
signals:
233
237
void
finished
();
238
239
private slots:
240
241
void
feedFrames();
242
void
checkStatus( QMediaRecorder::RecorderState state );
243
void
handleError( QMediaRecorder::Error
error
, const QString &
errorString
);
244
245
private:
246
QString mFileName;
247
QSize mSize;
248
QStringList mInputFiles;
249
double
mFramesPerSecond = 10;
250
qint64 mFrameDurationUs = 100000;
251
QMediaFormat::FileFormat mFormat = QMediaFormat::FileFormat::MPEG4;
252
QMediaFormat::VideoCodec mCodec = QMediaFormat::VideoCodec::H264;
253
QMediaRecorder::Error mError = QMediaRecorder::Error::NoError;
254
int
mCurrentFrameIndex = 0;
255
QPointer<
QgsFeedback
> mFeedback;
256
257
QString mErrorString;
258
259
std::unique_ptr< QMediaCaptureSession > mSession;
260
std::unique_ptr< QMediaRecorder > mRecorder;
261
#if QT_VERSION >= QT_VERSION_CHECK( 6, 8, 0 )
262
std::unique_ptr< QVideoFrameInput > mVideoInput;
263
#endif
264
};
265
266
267
#endif
// QGSVIDEOEXPORTER_H
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition
qgsfeedback.h:44
QgsNotSupportedException
Custom exception class which is raised when an operation is not supported.
Definition
qgsexception.h:111
QgsVideoExporter::finished
void finished()
Emitted when the video export finishes.
QgsVideoExporter::error
QMediaRecorder::Error error() const
Returns the last error received while writing the video.
Definition
qgsvideoexporter.cpp:107
QgsVideoExporter::frameDuration
qint64 frameDuration() const
Returns the duration of each frame, in micro-seconds.
Definition
qgsvideoexporter.h:89
QgsVideoExporter::errorString
QString errorString() const
Returns the string describing the last error received while writing the video.
Definition
qgsvideoexporter.cpp:112
QgsVideoExporter::QgsVideoExporter
QgsVideoExporter(const QString &filename, QSize size, double framesPerSecond)
Constructor for QgsVideoExporter.
Definition
qgsvideoexporter.cpp:44
QgsVideoExporter::framesPerSecond
double framesPerSecond() const
Returns the output video frames per second.
Definition
qgsvideoexporter.h:82
QgsVideoExporter::isAvailable
static bool isAvailable()
Returns true if the video export functionality is available on the current system.
Definition
qgsvideoexporter.cpp:35
QgsVideoExporter::setFeedback
void setFeedback(QgsFeedback *feedback)
Sets an optional feedback object, for progress reports and cancellation support.
Definition
qgsvideoexporter.cpp:54
QgsVideoExporter::size
QSize size() const
Returns the output video frame size.
Definition
qgsvideoexporter.h:94
QgsVideoExporter::feedback
QgsFeedback * feedback()
Returns the optional feedback object.
Definition
qgsvideoexporter.cpp:59
qgis_sip.h
SIP_THROW
#define SIP_THROW(name,...)
Definition
qgis_sip.h:215
Generated on
for QGIS API Documentation by
1.17.0