VideoRecording.qml
12.8 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
/* Webcamoid, webcam capture application.
* Copyright (C) 2020 Gonzalo Exequiel Pedone
*
* Webcamoid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Webcamoid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Webcamoid. If not, see <http://www.gnu.org/licenses/>.
*
* Web-Site: http://webcamoid.github.io/
*/
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import Qt.labs.platform as LABS
import Qt.labs.settings 1.0
import Ak
Page {
id: videoRecording
ScrollView {
id: scrollView
anchors.fill: parent
contentHeight: layout.height
clip: true
readonly property string filePrefix: Ak.platform() == "windows"?
"file:///":
"file://"
GridLayout {
id: layout
width: scrollView.width
columns: 3
Label {
id: txtVideosDirectory
text: qsTr("Videos directory")
}
TextField {
text: recording.videoDirectory
Accessible.name: txtVideosDirectory.text
selectByMouse: true
Layout.fillWidth: true
onTextChanged: recording.videoDirectory = text
}
Button {
text: qsTr("Search")
Accessible.description: qsTr("Search directory to save videos")
onClicked: {
mediaTools.makedirs(recording.videoDirectory)
folderDialog.open()
}
}
Label {
id: txtRecordAudio
text: qsTr("Record audio")
}
Switch {
Accessible.name: txtRecordAudio.text
Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
checked: recording.recordAudio
onToggled: recording.recordAudio = checked
}
Label {
text: qsTr("Video quality")
font: AkTheme.fontSettings.h6
Layout.topMargin: AkUnit.create(12 * AkTheme.controlScale, "dp").pixels
Layout.bottomMargin: AkUnit.create(12 * AkTheme.controlScale, "dp").pixels
Layout.columnSpan: 3
}
Label {
id: txtOutputWidth
text: qsTr("Output width")
}
SpinBox {
id: spbOutputWidth
value: AkVideoCaps.create(recording.videoCaps).width
from: 160
to: 32768
stepSize: 1
editable: true
Accessible.name: txtOutputWidth.text
Layout.columnSpan: 2
onValueChanged: {
let videoCaps = AkVideoCaps.create(recording.videoCaps)
videoCaps.width = value
recording.videoCaps = videoCaps.toVariant()
}
}
Label {
id: txtOutputHeight
text: qsTr("Output height")
}
SpinBox {
id: spbOutputHeight
value: AkVideoCaps.create(recording.videoCaps).height
from: 90
to: 32768
stepSize: 1
editable: true
Accessible.name: txtOutputHeight.text
Layout.columnSpan: 2
onValueChanged: {
let videoCaps = AkVideoCaps.create(recording.videoCaps)
videoCaps.height = value
recording.videoCaps = videoCaps.toVariant()
}
}
Label {
id: txtOutputFrameRate
text: qsTr("Output Frame rate")
}
SpinBox {
id: spbOutputFrameRate
value: Math.round(AkFrac.create(AkVideoCaps.create(recording.videoCaps).fps).value)
from: 1
to: 1024
stepSize: 1
editable: true
Accessible.name: txtOutputFrameRate.text
Layout.columnSpan: 2
onValueChanged: {
let videoCaps = AkVideoCaps.create(recording.videoCaps)
videoCaps.fps = AkFrac.create(value, 1).toVariant()
recording.videoCaps = videoCaps.toVariant()
}
}
Label {
text: qsTr("Audio quality")
font: AkTheme.fontSettings.h6
Layout.topMargin: AkUnit.create(12 * AkTheme.controlScale, "dp").pixels
Layout.bottomMargin: AkUnit.create(12 * AkTheme.controlScale, "dp").pixels
Layout.columnSpan: 3
}
Label {
id: txtAudioSampleRate
text: qsTr("Sample rate")
}
SpinBox {
id: spbAudioSampleRate
value: AkAudioCaps.create(recording.audioCaps).rate
from: 4000
to: 512000
stepSize: 1
editable: true
Accessible.name: txtAudioSampleRate.text
Layout.columnSpan: 2
onValueChanged: {
let audioCaps = AkAudioCaps.create(recording.audioCaps)
audioCaps.rate = value
recording.audioCaps = audioCaps.toVariant()
}
}
Label {
text: qsTr("File format and codecs")
font: AkTheme.fontSettings.h6
Layout.topMargin: AkUnit.create(12 * AkTheme.controlScale, "dp").pixels
Layout.bottomMargin: AkUnit.create(12 * AkTheme.controlScale, "dp").pixels
Layout.columnSpan: 3
}
Label {
id: txtFileFormat
text: qsTr("File format")
}
ComboBox {
id: cbxVideoFormat
Accessible.description: txtFileFormat.text
textRole: "description"
Layout.fillWidth: true
model: ListModel {
}
Component.onCompleted: {
model.clear()
let formats = recording.videoFormats
for (let i in formats) {
let fmt = formats[i]
model.append({
format: fmt,
description: recording.formatDescription(fmt)
})
}
currentIndex = formats.indexOf(recording.videoFormat)
}
onCurrentIndexChanged: {
if (currentIndex >= 0)
recording.videoFormat = model.get(currentIndex).format
cbxVideoCodec.update()
cbxAudioCodec.update()
}
}
Button {
id: configureVideoFormat
text: qsTr("Configure")
Accessible.description: qsTr("Configure file format")
flat: true
onClicked: videoFormatOptions.open()
}
Label {
id: txtVideoCodec
text: qsTr("Video codec")
}
ComboBox {
id: cbxVideoCodec
Accessible.description: txtVideoCodec.text
textRole: "description"
Layout.fillWidth: true
model: ListModel {
}
function update()
{
model.clear()
let codecs =
recording.supportedCodecs(recording.videoFormat,
AkCaps.CapsVideo);
for (let i in codecs) {
let cdc = codecs[i]
model.append({
codec: cdc,
description: recording.codecDescription(cdc)
})
}
let index =
codecs.indexOf(recording.codec(AkCaps.CapsVideo))
if (index < 0)
index =
codecs.indexOf(recording.defaultCodec(recording.videoFormat,
AkCaps.CapsVideo))
currentIndex = index
}
Component.onCompleted: update()
onCurrentIndexChanged: {
if (currentIndex >= 0)
recording.setCodec(AkCaps.CapsVideo,
model.get(currentIndex).codec)
}
}
Button {
id: configureVideoCodec
text: qsTr("Configure")
Accessible.description: qsTr("Configure video codec")
flat: true
onClicked: videoCodecOptions.open()
}
Label {
id: txtAudioCodec
text: qsTr("Audio codec")
enabled: recording.recordAudio
}
ComboBox {
id: cbxAudioCodec
Accessible.description: txtAudioCodec.text
textRole: "description"
Layout.fillWidth: true
enabled: recording.recordAudio
model: ListModel {
}
function update()
{
model.clear()
let codecs =
recording.supportedCodecs(recording.videoFormat,
AkCaps.CapsAudio);
for (let i in codecs) {
let cdc = codecs[i]
model.append({
codec: cdc,
description: recording.codecDescription(cdc)
})
}
let index =
codecs.indexOf(recording.codec(AkCaps.CapsAudio))
if (index < 0)
index =
codecs.indexOf(recording.defaultCodec(recording.videoFormat,
AkCaps.CapsAudio))
currentIndex = index
}
Component.onCompleted: update()
onCurrentIndexChanged: {
if (currentIndex >= 0)
recording.setCodec(AkCaps.CapsAudio,
model.get(currentIndex).codec)
}
}
Button {
id: configureAudioCodec
text: qsTr("Configure")
Accessible.description: qsTr("Configure audio codec")
enabled: recording.recordAudio
flat: true
onClicked: audioCodecOptions.open()
}
}
}
VideoFormatOptions {
id: videoFormatOptions
width: videoRecording.Window.width
height: videoRecording.Window.height
anchors.centerIn: Overlay.overlay
onClosed: configureVideoFormat.forceActiveFocus()
}
VideoCodecOptions {
id: videoCodecOptions
width: videoRecording.Window.width
height: videoRecording.Window.height
anchors.centerIn: Overlay.overlay
onClosed: configureVideoCodec.forceActiveFocus()
}
AudioCodecOptions {
id: audioCodecOptions
width: videoRecording.Window.width
height: videoRecording.Window.height
anchors.centerIn: Overlay.overlay
onClosed: configureAudioCodec.forceActiveFocus()
}
LABS.FolderDialog {
id: folderDialog
title: qsTr("Select the folder to save your videos")
folder: scrollView.filePrefix + recording.videoDirectory
onAccepted: {
recording.videoDirectory =
currentFolder.toString().replace(scrollView.filePrefix, "")
}
}
Settings {
category: "RecordConfigs"
property alias outputWidth: spbOutputWidth.value
property alias outputHeight: spbOutputHeight.value
property alias outputFPS: spbOutputFrameRate.value
property alias audioSampleRate: spbAudioSampleRate.value
}
}