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;
39class Filter;
40}
41
42class PresetsProxyModel : public QSortFilterProxyModel
43{
44protected:
45 bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
46};
47
48class EncodeDock : public QDockWidget
49{
50 Q_OBJECT
51
52public:
53 explicit EncodeDock(QWidget *parent = 0);
54 ~EncodeDock();
55
56 void loadPresetFromProperties(Mlt::Properties &);
57 bool isExportInProgress() const;
58 bool isResampleEnabled() const;
59
60signals:
61 void captureStateChanged(bool);
62 void createOrEditFilterOnOutput(Mlt::Filter *, const QStringList & = {});
63
64public slots:
65 void onAudioChannelsChanged();
66 void onProducerOpened();
67 void onProfileChanged();
68 void on_hwencodeButton_clicked();
69 bool detectHardwareEncoders();
70
71private slots:
72 void on_presetsTree_clicked(const QModelIndex &index);
73 void on_presetsTree_activated(const QModelIndex &index);
74
75 void on_encodeButton_clicked();
76
77 void on_streamButton_clicked();
78
79 void on_addPresetButton_clicked();
80
81 void on_removePresetButton_clicked();
82
83 void onFinished(AbstractJob *, bool isSuccess);
84
85 void on_stopCaptureButton_clicked();
86
87 void on_videoRateControlCombo_activated(int index);
88
89 void on_audioRateControlCombo_activated(int index);
90
91 void on_scanModeCombo_currentIndexChanged(int index);
92
93 void on_presetsSearch_textChanged(const QString &search);
94
95 void on_resetButton_clicked();
96
97 void openCaptureFile();
98
99 void on_formatCombo_currentIndexChanged(int index);
100
101 void on_videoBufferDurationChanged();
102
103 void on_gopSpinner_valueChanged(int value);
104
105 void on_fromCombo_currentIndexChanged(int index);
106
107 void on_videoCodecCombo_currentIndexChanged(int index);
108
109 void on_audioCodecCombo_currentIndexChanged(int index);
110
111 void setAudioChannels( int channels );
112
113 void on_widthSpinner_editingFinished();
114
115 void on_heightSpinner_editingFinished();
116
117 void on_advancedButton_clicked(bool checked);
118
119 void on_hwencodeCheckBox_clicked(bool checked);
120
121 void on_advancedCheckBox_clicked(bool checked);
122
123 void on_fpsSpinner_editingFinished();
124
125 void on_fpsComboBox_activated(int arg1);
126
127 void on_videoQualitySpinner_valueChanged(int vq);
128
129 void on_audioQualitySpinner_valueChanged(int aq);
130
131 void on_parallelCheckbox_clicked(bool checked);
132
133 void on_resolutionComboBox_activated(int arg1);
134
135 void on_reframeButton_clicked();
136
137 void on_resampleButton_clicked(bool checked);
138
139private:
140 enum {
141 RateControlAverage = 0,
142 RateControlConstant,
143 RateControlQuality,
144 RateControlConstrained
145 };
146 enum {
147 AudioChannels1 = 0,
148 AudioChannels2,
149 AudioChannels4,
150 AudioChannels6,
151 };
152 Ui::EncodeDock *ui;
153 Mlt::Properties *m_presets;
154 QScopedPointer<MeltJob> m_immediateJob;
155 QString m_extension;
156 Mlt::Properties *m_profiles;
157 PresetsProxyModel m_presetsModel;
158 QStringList m_outputFilenames;
159 bool m_isDefaultSettings;
160 double m_fps;
161 QStringList m_intraOnlyCodecs;
162 QStringList m_losslessVideoCodecs;
163 QStringList m_losslessAudioCodecs;
164
165 void loadPresets();
166 Mlt::Properties *collectProperties(int realtime, bool includeProfile = false);
167 void collectProperties(QDomElement &node, int realtime);
168 void setSubtitleProperties(QDomElement &node, Mlt::Producer *service);
169 QPoint addConsumerElement(Mlt::Producer *service, QDomDocument &dom, const QString &target,
170 int realtime, int pass);
171 MeltJob *createMeltJob(Mlt::Producer *service, const QString &target, int realtime, int pass = 0,
172 const QThread::Priority priority = Settings.jobPriority());
173 void runMelt(const QString &target, int realtime = -1);
174 void enqueueAnalysis();
175 void enqueueMelt(const QStringList &targets, int realtime);
176 void encode(const QString &target);
177 void resetOptions();
178 Mlt::Producer *fromProducer() const;
179 static void filterCodecParams(const QString &vcodec, QStringList &other);
180 void onVideoCodecComboChanged(int index, bool ignorePreset = false, bool resetBframes = true);
181 bool checkForMissingFiles();
182 QString &defaultFormatExtension();
183 void initSpecialCodecLists();
184 void setResampleEnabled(bool enabled);
185};
186
187#endif // ENCODEDOCK_H