Krita Source Code Documentation
Loading...
Searching...
No Matches
KisFFMpegWrapper.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Dmitrii Utkin <loentar@gmail.com>
3 * SPDX-FileCopyrightText: 2021 Eoin O'Neill <eoinoneill1991@gmail.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.1-only
6 */
7
8#ifndef KISFFMPEGWRAPPER_H
9#define KISFFMPEGWRAPPER_H
10
11#include <QObject>
12#include <QProgressDialog>
13
16
17#include <kritaui_export.h>
18
19class QProcess;
20
21struct KRITAUI_EXPORT KisFFMpegWrapperSettings
22{
23 QString processPath;
25 QString outputFile;
26 bool storeOutput = false;
27 QString logPath = "";
28 QStringList defaultPrependArgs = {"-hide_banner", "-y"};
29 bool batchMode = false;
30 bool binaryOutput = false;
31 int totalFrames = 0;
32
33 QString progressMessage = "";
34 bool progressIndeterminate = false;
35
36};
37
43
44const int FFMPEG_TIMEOUT = 600000;
45
46class KRITAUI_EXPORT KisFFMpegWrapper : public QObject
47{
48 Q_OBJECT
49public:
50 explicit KisFFMpegWrapper(QObject *parent = nullptr);
52
53 void startNonBlocking(const KisFFMpegWrapperSettings &settings);
55 bool waitForFinished(int msecs = FFMPEG_TIMEOUT);
56 void reset();
57
58 static QJsonObject findProcessPath(const QString &processName, const QString &customLocation, bool processInfo);
59 static QJsonObject findProcessInfo(const QString &processName, const QString &processPath, bool includeProcessInfo);
60 static QStringList getSupportedCodecs(const QJsonObject& ffmpegJsonProcessInput);
61 static QJsonObject findFFMpeg(const QString &customLocation);
62 static QJsonObject findFFProbe(const QString &customLocation);
63 static QByteArray runProcessAndReturn(const QString &processPath, const QStringList &args, int msecs = FFMPEG_TIMEOUT);
64 static QString configuredFFMpegLocation();
65 static void setConfiguredFFMpegLocation(QString& location);
66 QJsonObject ffprobe(const QString &inputFile, const QString &ffprobePath);
67 QJsonObject ffmpegProbe(const QString &inputFile, const QString &ffmpegPath, bool batchMode);
68
69 // Functions to convert the ffprobe shorthands for the H.273 constants into the appropriate enum values.
70 static ColorPrimaries colorPrimariesFromName(QString name);
71 static TransferCharacteristics transferCharacteristicsFromName(QString name);
72
73Q_SIGNALS:
74 void sigStarted();
76 void sigFinishedWithError(QString message);
77 void sigProgressUpdated(int frameNo);
78 void sigReadLine(int pipe, QString line);
79 void sigReadSTDOUT(QByteArray stdoutBuffer);
80 void sigReadSTDERR(QByteArray stderrBuffer);
81
82private Q_SLOTS:
83 void slotReadyReadSTDOUT();
84 void slotReadyReadSTDERR();
85 void slotStarted();
86 void slotFinished(int exitCode);
87
88private:
89 void updateProgressDialog(int progressValue);
90
97 bool ffprobeCheckStreamsValid(const QJsonObject& ffprobeJsonObj, const QString& ffprobeSTDERR);
98
99 static void fixUpNonEmbeddedProcessEnvironment(const QString &processPath, QProcess &process);
100
101private:
102 QScopedPointer<QProcess> m_process;
105
109
110 QByteArray m_processSTDOUT;
112
113};
114
115
116#endif // KISFFMPEGWRAPPER_H
FFProbeErrorCodes
@ INVALID_JSON
@ UNSUPPORTED_CODEC
@ NONE
const int FFMPEG_TIMEOUT
ColorPrimaries
The colorPrimaries enum Enum of colorants, follows ITU H.273 for values 0 to 255, and has extra known...
TransferCharacteristics
The transferCharacteristics enum Enum of transfer characteristics, follows ITU H.273 for values 0 to ...
KisFFMpegWrapperSettings m_processSettings
void sigProgressUpdated(int frameNo)
void sigReadLine(int pipe, QString line)
QByteArray m_processSTDOUT
void sigReadSTDOUT(QByteArray stdoutBuffer)
void sigReadSTDERR(QByteArray stderrBuffer)
void sigFinishedWithError(QString message)
QScopedPointer< QProcess > m_process