CuteLogger
Fast and simple logging solution for Qt based applications
encodedock.h
1/*
2 * Copyright (c) 2012-2024 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef ENCODEDOCK_H
19#define ENCODEDOCK_H
20
21#include "settings.h"
22
23#include <QDockWidget>
24#include <QDomElement>
25#include <QStandardItemModel>
26#include <QSortFilterProxyModel>
27#include <QStringList>
28#include <MltProperties.h>
29
30class QTreeWidgetItem;
31namespace Ui {
32class EncodeDock;
33}
34class AbstractJob;
35class MeltJob;
36namespace Mlt {
37class Service;
38class Producer;
39}
40
41class PresetsProxyModel : public QSortFilterProxyModel
42{
43protected:
44 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
45};
46
47class EncodeDock : public QDockWidget
48{
49 Q_OBJECT
50
51public:
52 explicit EncodeDock(QWidget *parent = 0);
53 ~EncodeDock();
54
55 void loadPresetFromProperties(Mlt::Properties &);
56 bool isExportInProgress() const;
57
58signals:
59 void captureStateChanged(bool);
60
61public slots:
62 void onAudioChannelsChanged();
63 void onProducerOpened();
64 void onProfileChanged();
65 void on_hwencodeButton_clicked();
66 bool detectHardwareEncoders();
67
68private slots:
69 void on_presetsTree_clicked(const QModelIndex &index);
70 void on_presetsTree_activated(const QModelIndex &index);
71
72 void on_encodeButton_clicked();
73
74 void on_streamButton_clicked();
75
76 void on_addPresetButton_clicked();
77
78 void on_removePresetButton_clicked();
79
80 void onFinished(AbstractJob *, bool isSuccess);
81
82 void on_stopCaptureButton_clicked();
83
84 void on_videoRateControlCombo_activated(int index);
85
86 void on_audioRateControlCombo_activated(int index);
87
88 void on_scanModeCombo_currentIndexChanged(int index);
89
90 void on_presetsSearch_textChanged(const QString &search);
91
92 void on_resetButton_clicked();
93
94 void openCaptureFile();
95
96 void on_formatCombo_currentIndexChanged(int index);
97
98 void on_videoBufferDurationChanged();
99
100 void on_gopSpinner_valueChanged(int value);
101
102 void on_fromCombo_currentIndexChanged(int index);
103
104 void on_videoCodecCombo_currentIndexChanged(int index);
105
106 void on_audioCodecCombo_currentIndexChanged(int index);
107
108 void setAudioChannels( int channels );
109
110 void on_widthSpinner_editingFinished();
111
112 void on_heightSpinner_editingFinished();
113
114 void on_advancedButton_clicked(bool checked);
115
116 void on_hwencodeCheckBox_clicked(bool checked);
117
118 void on_advancedCheckBox_clicked(bool checked);
119
120 void on_fpsSpinner_editingFinished();
121
122 void on_fpsComboBox_activated(int arg1);
123
124 void on_videoQualitySpinner_valueChanged(int vq);
125
126 void on_audioQualitySpinner_valueChanged(int aq);
127
128 void on_parallelCheckbox_clicked(bool checked);
129
130 void on_resolutionComboBox_activated(int arg1);
131
132private:
133 enum {
134 RateControlAverage = 0,
135 RateControlConstant,
136 RateControlQuality,
137 RateControlConstrained
138 };
139 enum {
140 AudioChannels1 = 0,
141 AudioChannels2,
142 AudioChannels4,
143 AudioChannels6,
144 };
145 Ui::EncodeDock *ui;
146 Mlt::Properties *m_presets;
147 QScopedPointer<MeltJob> m_immediateJob;
148 QString m_extension;
149 Mlt::Properties *m_profiles;
150 PresetsProxyModel m_presetsModel;
151 QStringList m_outputFilenames;
152 bool m_isDefaultSettings;
153 double m_fps;
154 QStringList m_intraOnlyCodecs;
155 QStringList m_losslessVideoCodecs;
156 QStringList m_losslessAudioCodecs;
157
158 void loadPresets();
159 Mlt::Properties *collectProperties(int realtime, bool includeProfile = false);
160 void collectProperties(QDomElement &node, int realtime);
161 void setSubtitleProperties(QDomElement &node, Mlt::Producer *service);
162 MeltJob *createMeltJob(Mlt::Producer *service, const QString &target, int realtime, int pass = 0,
163 const QThread::Priority priority = Settings.jobPriority());
164 void runMelt(const QString &target, int realtime = -1);
165 void enqueueAnalysis();
166 void enqueueMelt(const QStringList &targets, int realtime);
167 void encode(const QString &target);
168 void resetOptions();
169 Mlt::Producer *fromProducer() const;
170 static void filterCodecParams(const QString &vcodec, QStringList &other);
171 void onVideoCodecComboChanged(int index, bool ignorePreset = false, bool resetBframes = true);
172 bool checkForMissingFiles();
173 QString &defaultFormatExtension();
174 void initSpecialCodecLists();
175};
176
177#endif // ENCODEDOCK_H