-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgifprocessor.h
More file actions
60 lines (47 loc) · 1.71 KB
/
Copy pathgifprocessor.h
File metadata and controls
60 lines (47 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef GIFPROCESSOR_H
#define GIFPROCESSOR_H
#include <QObject>
#include <QString>
#include <QVector>
// 压缩参数结构体
struct CompressionParams {
int colors;
int quality;
double scale;
double fps;
QString name;
};
class GifProcessor : public QObject {
Q_OBJECT
public:
explicit GifProcessor(QObject *parent = nullptr);
~GifProcessor();
void setInputPath(const QString &path) { m_inputPath = path; }
void setOutputDir(const QString &dir) { m_outputDir = dir; }
public slots:
void process();
signals:
void progressUpdated(int percent);
void statusMessage(const QString &message);
void finished(const QStringList &outputFiles);
void error(const QString &message);
void sizeWarning(const QString &message); // 大小警告信号
private:
CompressionParams findOptimalParams(const QString &ffmpegPath,
const QString &inputPath, int cropWidth,
int height, int left, double targetFps,
int targetSizeMB);
bool compressWithUnifiedParams(const QString &ffmpegPath,
const QString &inputPath,
const QString &outputPath, int cropWidth,
int height, int left,
const CompressionParams ¶ms,
int pieceNum); // 添加 pieceNum 参数
double getGifFrameRate(const QString &ffprobePath, const QString &gifPath);
bool verifyAlignment(const QStringList &outputFiles);
void fixGifForSteam(const QString &gifPath);
QString m_inputPath;
QString m_outputDir;
static constexpr int TARGET_SIZE_MB = 5;
};
#endif // GIFPROCESSOR_H