Krita Source Code Documentation
Loading...
Searching...
No Matches
VideoExportOptionsDialog.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8#include "ui_video_export_options_dialog.h"
9
10#include <KoID.h>
11
12#include <ksharedconfig.h>
13#include <kconfiggroup.h>
15
16
18{
19 Private(ContainerType _containerType, const QStringList& validEncoders)
20 : containerType(_containerType)
21 {
23
24 // Cross check w/ arbitrary ffmpeg's list of present encoders if list is populated.
25 if (validEncoders.size() > 0) {
26 encoders = [validEncoders](const QVector<KoID>& input) -> QVector<KoID> {
27 QVector<KoID> filtered;
28 Q_FOREACH(const KoID& encoder, input) {
29 if (validEncoders.contains(encoder.id())) {
30 filtered << encoder;
31 }
32 }
33
34 return filtered;
35 }(encoders);
36 }
37
38 presetsXH264 << KoID("ultrafast", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "ultrafast"));
39 presetsXH264 << KoID("superfast", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "superfast"));
40 presetsXH264 << KoID("veryfast", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "veryfast"));
41 presetsXH264 << KoID("faster", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "faster"));
42 presetsXH264 << KoID("fast", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "fast"));
43 presetsXH264 << KoID("medium", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "medium"));
44 presetsXH264 << KoID("slow", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "slow"));
45 presetsXH264 << KoID("slower", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "slower"));
46 presetsXH264 << KoID("veryslow", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "veryslow"));
47 presetsXH264 << KoID("placebo", i18nc("h264 preset name, check simplescreenrecorder for standard translations", "placebo"));
48
49 profilesXH264 << KoID("baseline", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "baseline"));
50 profilesXH264 << KoID("main", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "main"));
51 profilesXH264 << KoID("high", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "high"));
52 profilesXH264 << KoID("high10", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "high10"));
53 profilesXH264 << KoID("high422", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "high422"));
54 profilesXH264 << KoID("high444", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "high444"));
55
56 profilesXH265 << KoID("main", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "main"));
57 profilesXH265 << KoID("main10", i18nc("h264 profile name, check simplescreenrecorder for standard translations", "main10 (HDR)"));
58
59 // TODO: add "none" tune option
60 tuningXH264 << KoID("film", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "film"));
61 tuningXH264 << KoID("animation", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "animation"));
62 tuningXH264 << KoID("grain", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "grain"));
63 tuningXH264 << KoID("stillimage", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "stillimage"));
64 tuningXH264 << KoID("psnr", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "psnr"));
65 tuningXH264 << KoID("ssim", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "ssim"));
66 tuningXH264 << KoID("fastdecode", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "fastdecode"));
67 tuningXH264 << KoID("zerolatency", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "zerolatency"));
68
69 tuningXH265 << KoID("none", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "none"));
70 tuningXH265 << KoID("animation", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "animation"));
71 tuningXH265 << KoID("grain", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "grain"));
72 tuningXH265 << KoID("psnr", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "psnr"));
73 tuningXH265 << KoID("ssim", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "ssim"));
74 tuningXH265 << KoID("fastdecode", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "fastdecode"));
75 tuningXH265 << KoID("zero-latency", i18nc("h264 tune option name, check simplescreenrecorder for standard translations", "zero-latency"));
76
77 predAPNG << KoID("none", i18nc("apng prediction option name", "none"));
78 predAPNG << KoID("sub", i18nc("apng prediction option name", "sub"));
79 predAPNG << KoID("up", i18nc("apng prediction option name", "up"));
80 predAPNG << KoID("avg", i18nc("apng prediction option name", "avg"));
81 predAPNG << KoID("paeth", i18nc("apng prediction option name", "paeth"));
82 predAPNG << KoID("mixed", i18nc("apng prediction option name", "mixed"));
83
84 presetsWEBP << KoID("default", i18nc("webp preset option name", "default"));
85 presetsWEBP << KoID("none", i18nc("webp preset option name", "none"));
86 presetsWEBP << KoID("drawing", i18nc("webp preset option name", "drawing"));
87 presetsWEBP << KoID("icon", i18nc("webp preset option name", "icon"));
88 presetsWEBP << KoID("photo", i18nc("webp preset option name", "photo"));
89 presetsWEBP << KoID("picture", i18nc("webp preset option name", "picture"));
90 presetsWEBP << KoID("text", i18nc("webp preset option name", "text"));
91
92 paletteGenModeGIF << KoID("full", i18nc("palettegen status mode option name", "Global/Full"));
93 paletteGenModeGIF << KoID("diff", i18nc("palettegen status mode option name", "Difference"));
94 paletteGenModeGIF << KoID("single", i18nc("palettegen status mode option name", "Per Single Frame"));
95
96 paletteDitherGIF << KoID("none", i18nc("paletteuse dither option name", "none"));
97 paletteDitherGIF << KoID("bayer", i18nc("paletteuse dither option name", "bayer"));
98 paletteDitherGIF << KoID("floyd_steinberg", i18nc("paletteuse dither option name", "floyd_steinberg"));
99 paletteDitherGIF << KoID("heckbert", i18nc("paletteuse dither option name", "heckbert"));
100 paletteDitherGIF << KoID("sierra2", i18nc("paletteuse dither option name", "sierra2"));
101 paletteDitherGIF << KoID("sierra2_4a", i18nc("paletteuse dither option name", "sierra2_4a"));
102
103 paletteDiffModeGIF << KoID("none", i18nc("paletteuse diff mode option name", "none"));
104 paletteDiffModeGIF << KoID("rectangle", i18nc("paletteuse diff mode option name", "rectangle"));
105 }
106
111
113
117
121
123
125
127 bool supportsHDR = false;
128};
129
130void populateComboWithKoIds(QComboBox *combo, const QVector<KoID> &ids, int defaultIndex)
131{
132 Q_FOREACH (const KoID &id, ids) {
133 combo->insertItem(combo->count(), id.name());
134 }
135 combo->setCurrentIndex(defaultIndex);
136 combo->setEnabled(combo->count() > 1);
137}
138
140 : KisConfigWidget(parent),
141 ui(new Ui::VideoExportOptionsDialog),
142 m_d(new Private(containerType, validEncoders))
143{
144 ui->setupUi(this);
145
146 ui->intOpenH264bitrate->setRange(100, 10000);
147 ui->intOpenH264bitrate->setValue(5000);
148 ui->intOpenH264bitrate->setSuffix(i18nc("kilo-bits-per-second, video bitrate suffix", "kbps"));
149
150 ui->intCRFH264->setRange(0, 51);
151 ui->intCRFH264->setValue(28);
152
153 ui->intCRFH265->setRange(0, 51);
154 ui->intCRFH265->setValue(28);
155
156 populateComboWithKoIds(ui->cmbPresetH264, m_d->presetsXH264, 5);
157 populateComboWithKoIds(ui->cmbPresetH265, m_d->presetsXH264, 5);
158
159 populateComboWithKoIds(ui->cmbProfileH264, m_d->profilesXH264, 0);
160 populateComboWithKoIds(ui->cmbProfileH265, m_d->profilesXH265, 0);
161
162 populateComboWithKoIds(ui->cmbTuneH264, m_d->tuningXH264, 0);
163 populateComboWithKoIds(ui->cmbTuneH265, m_d->tuningXH265, 0);
164
165 ui->intBitrate->setRange(10, 50000);
166 ui->intBitrate->setValue(5000);
167 ui->intBitrate->setSuffix(i18nc("kilo-bits-per-second, video bitrate suffix", "kbps"));
168
169 // Alpha is stored in WebM/Matroska block additions, not in the VP9 stream
170 // itself. MP4 cannot carry this transparency data.
171 ui->vp9PreserveTransparency->setEnabled(containerType == WEBM || containerType == MKV);
172
173 ui->gifReserveTransparent->setChecked(true);
174 ui->gifLoop->setChecked(true);
175 ui->gifTransDiff->setChecked(true);
176
177 populateComboWithKoIds(ui->cmbPalettegenStatsModeGIF, m_d->paletteGenModeGIF, 0);
178 populateComboWithKoIds(ui->cmbPaletteuseDitherGIF, m_d->paletteDitherGIF, 5);
179 populateComboWithKoIds(ui->cmbPaletteuseDiffModeGIF, m_d->paletteDiffModeGIF, 0);
180
181 ui->intPaletteuseBayerScaleGIF->setRange(0, 5);
182 ui->intPaletteuseBayerScaleGIF->setValue(2);
183
184 ui->apngLoop->setChecked(true);
185
186 populateComboWithKoIds(ui->cmbPredAPNG, m_d->predAPNG, 0);
187
188 ui->intCompressWEBP->setRange(0, 6);
189 ui->intCompressWEBP->setValue(4);
190
191 ui->intQscaleWEBP->setRange(0, 100);
192 ui->intQscaleWEBP->setValue(75);
193
194 populateComboWithKoIds(ui->cmbPresetWEBP, m_d->presetsWEBP, 0);
195
196 ui->webpLoop->setChecked(true);
197
198 populateComboWithKoIds(ui->cmbCodec, m_d->encoders, 0);
199 connect(ui->cmbCodec, SIGNAL(currentIndexChanged(int)), SLOT(slotCodecSelected(int)));
201
202 // TODO: temporarily hidden! Some combinations of 'tune' and
203 // 'profile' options make ffmpeg generate empty file.
204 // We should not let the user shoot into his own foot!
205 ui->cmbTuneH264->setVisible(false);
206 ui->lblTuneH264->setVisible(false);
207
208 ui->cmbTuneH265->setVisible(false);
209 ui->lblTuneH265->setVisible(false);
210
212 connect(ui->chkCustomLine, SIGNAL(toggled(bool)), SLOT(slotCustomLineToggled(bool)));
213 connect(ui->txtCustomLine, SIGNAL(editingFinished()), SLOT(slotSaveCustomLine()));
214 connect(ui->btnResetCustomLine, SIGNAL(clicked()), SLOT(slotResetCustomLine()));
215
216 connect(ui->cmbProfileH265,
217 SIGNAL(currentIndexChanged(int)),
218 SLOT(slotH265ProfileChanged(int)));
219 slotH265ProfileChanged(ui->cmbProfileH265->currentIndex());
220
221
222 connect(ui->cmbPaletteuseDitherGIF,
223 SIGNAL(currentIndexChanged(int)),
224 SLOT(slotBayerFilterSelected(int)));
225
226 slotBayerFilterSelected(ui->cmbPaletteuseDitherGIF->currentIndex());
227
228 setSupportsHDR(false);
229 m_d->hdrMetadataOptions = hdrOptions;
230}
231
236
238{
239 m_d->supportsHDR = value;
240 slotH265ProfileChanged(ui->cmbProfileH265->currentIndex());
241}
242
244{
246
247 cfg->setProperty("CodecId", currentCodecId());
248
249 cfg->setProperty("Openh264Bitrate", ui->intOpenH264bitrate->value());
250
251 cfg->setProperty("h264PresetIndex", ui->cmbPresetH264->currentIndex());
252 cfg->setProperty("h264ConstantRateFactor", ui->intCRFH264->value());
253 cfg->setProperty("h264ProfileIndex", ui->cmbProfileH264->currentIndex());
254 cfg->setProperty("h264TuneIndex", ui->cmbTuneH264->currentIndex());
255
256 cfg->setProperty("h265PresetIndex", ui->cmbPresetH265->currentIndex());
257 cfg->setProperty("h265ConstantRateFactor", ui->intCRFH265->value());
258 cfg->setProperty("h265ProfileIndex", ui->cmbProfileH265->currentIndex());
259 cfg->setProperty("h265TuneIndex", ui->cmbTuneH265->currentIndex());
260 cfg->setProperty("h265UseHDRMetadata", ui->chkUseHDRMetadata->isChecked());
261
262 cfg->setProperty("TheoraBitrate", ui->intBitrate->value());
263 cfg->setProperty("vp9PreserveTransparency", ui->vp9PreserveTransparency->isChecked());
264 cfg->setProperty("vp9Lossless", ui->vp9Lossless->isChecked());
265 cfg->setProperty("vp9Mbits", ui->vp9Mbits->value());
266 cfg->setProperty("CustomLineValue", ui->txtCustomLine->text());
267 cfg->setProperty("customUserOptions", customUserOptions().join(' '));
268
269 cfg->setPrefixedProperties("hdrMetadata/", m_d->hdrMetadataOptions.toProperties());
270
271 return cfg;
272}
273
275{
276 if (mimeType == "video/webm") {
277 return ContainerType::WEBM;
278 } else if (mimeType == "video/x-matroska") {
279 return ContainerType::MKV;
280 } else if (mimeType == "video/quicktime") {
281 return ContainerType::MOV;
282 } else if (mimeType == "video/ogg") {
283 return ContainerType::OGV;
284 } else if (mimeType == "image/gif") {
285 return ContainerType::GIF;
286 } else if (mimeType == "image/apng") {
287 return ContainerType::APNG;
288 } else if (mimeType == "image/webp") {
289 return ContainerType::WEBP;
290 }
291
293}
294
296{
297 KIS_ASSERT(type < ContainerType::NUM_CONTAINER_TYPE && type >= ContainerType::DEFAULT);
298 QVector<KoID> encoders;
299 QVector<KoID> h264Encoders = {
300 KoID("libopenh264", i18nc("openh264 codec name", "OpenH264")),
301 KoID("libx264", i18nc("h264 codec name, check simplescreenrecorder for standard translations", "H.264, MPEG-4 Part 10")),
302 KoID("libx265", i18nc("h265 codec name, check simplescreenrecorder for standard translations", "H.265, MPEG-H Part 2 (HEVC)"))
303 };
304
305 KoID vp9Encoder = KoID("libvpx-vp9", i18nc("VP9 codec name", "VP9"));
306
307
308 switch (type) {
310 encoders << KoID("prores_ks", i18nc("ProRes codec name", "ProRes 4444 (with transparency)"));
311 break;
313 encoders << KoID("libtheora", i18nc("theora codec name, check simplescreenrecorder for standard translations", "Theora"));
314 break;
316 encoders << KoID("libwebp", i18nc("WEBP codec name", "WEBP"));
317 break;
319 encoders << KoID("apng", i18nc("APNG codec name", "APNG"));
320 break;
322 encoders << KoID("gif", i18nc("GIF codec name", "GIF"));
323 break;
325 encoders << vp9Encoder;
326 break;
329 default:
330 encoders << h264Encoders;
331 encoders << vp9Encoder;
332 break;
333 }
334
335 return encoders;
336}
337
339{
340 QString customLine = m_d->currentCustomLine;
341
342 if (m_d->currentCustomLine.isEmpty() && value) {
343 customLine = generateCustomLine().join(" ");
344 } else if (!value) {
345 customLine = QString();
346 m_d->currentCustomLine = QString();
347 }
348
349 ui->txtCustomLine->setText(customLine);
350
351 ui->stackedWidget->setEnabled(!value);
352 ui->txtCustomLine->setEnabled(value);
353 ui->btnResetCustomLine->setEnabled(value);
354}
355
357{
358 ui->txtCustomLine->setText(generateCustomLine().join(" "));
360}
361
363{
364 const QString codec = m_d->encoders[index].id();
365 if (codec == "libopenh264") {
366 ui->stackedWidget->setCurrentIndex(CODEC_OPENH264);
367 } else if (codec == "libx264") {
368 ui->stackedWidget->setCurrentIndex(CODEC_H264);
369 } else if (codec == "libx265") {
370 ui->stackedWidget->setCurrentIndex(CODEC_H265);
371 } else if (codec == "libtheora") {
372 ui->stackedWidget->setCurrentIndex(CODEC_THEORA);
373 } else if (codec == "libvpx-vp9") {
374 ui->stackedWidget->setCurrentIndex(CODEC_VP9);
375 } else if (codec == "gif") {
376 ui->stackedWidget->setCurrentIndex(CODEC_GIF);
377 } else if (codec == "apng") {
378 ui->stackedWidget->setCurrentIndex(CODEC_APNG);
379 } else if (codec == "libwebp") {
380 ui->stackedWidget->setCurrentIndex(CODEC_WEBP);
381 } else if (codec == "prores_ks") {
382 ui->stackedWidget->setCurrentIndex(CODEC_PRORES);
383 }
384}
385
387{
388 m_d->currentCustomLine = ui->txtCustomLine->text();
389}
390
392{
393 return ui->chkCustomLine->isChecked() ?
394 ui->txtCustomLine->text().split(" ", Qt::SkipEmptyParts) :
396}
397
399{
400 return customUserOptions().join(' ');
401}
402
404{
405 return currentCodecId() == "libx265" &&
406 ui->chkUseHDRMetadata->isEnabled() &&
407 ui->chkUseHDRMetadata->isChecked();
408}
409
411 if (value && currentCodecId() != "libx265") {
412 ui->cmbCodec->setCurrentIndex(m_d->encoders.indexOf(KoID("libx265")));
413 ui->chkUseHDRMetadata->setEnabled(true);
414 }
415
416 //If HDR is enabled && the codec id is correct, we need to use main10.
417 if (value && currentCodecId() == "libx265") {
418 ui->cmbProfileH265->setCurrentIndex(m_d->profilesXH265.indexOf(KoID("main10")));
419 }
420
421 ui->chkUseHDRMetadata->setChecked(value);
422}
423
424int findIndexById(const QString &id, const QVector<KoID> &ids)
425{
426 int index = -1;
427 auto it = std::find_if(ids.begin(), ids.end(), kismpl::mem_equal_to(&KoID::id, id));
428 if (it != ids.end()) {
429 index = std::distance(ids.begin(), it);
430 }
431
432 return index;
433}
434
436{
437 ui->intOpenH264bitrate->setValue(cfg->getInt("Openh264Bitrate", 5000));
438
439 ui->cmbPresetH264->setCurrentIndex(cfg->getInt("h264PresetIndex", 5));
440 ui->intCRFH264->setValue(cfg->getInt("h264ConstantRateFactor", 23));
441 ui->cmbProfileH264->setCurrentIndex(cfg->getInt("h264ProfileIndex", 0));
442 ui->cmbTuneH264->setCurrentIndex(cfg->getInt("h264TuneIndex", 1));
443
444 ui->cmbPresetH265->setCurrentIndex(cfg->getInt("h265PresetIndex", 5));
445 ui->intCRFH265->setValue(cfg->getInt("h265ConstantRateFactor", 23));
446 ui->cmbProfileH265->setCurrentIndex(cfg->getInt("h265ProfileIndex", 0));
447 ui->cmbTuneH265->setCurrentIndex(cfg->getInt("h265TuneIndex", 1));
448 ui->chkUseHDRMetadata->setChecked(cfg->getBool("h265UseHDRMetadata", false));
449
450 ui->intBitrate->setValue(cfg->getInt("TheoraBitrate", 5000));
451 ui->vp9PreserveTransparency->setChecked(cfg->getBool("vp9PreserveTransparency", false));
452 ui->vp9Lossless->setChecked(cfg->getBool("vp9Lossless", false));
453 ui->vp9Mbits->setValue(cfg->getInt("vp9Mbits", 2));
454
455 m_d->currentCustomLine = cfg->getString("CustomLineValue", QString());
456 ui->chkCustomLine->setChecked(!m_d->currentCustomLine.isEmpty());
457 slotCustomLineToggled(ui->chkCustomLine->isChecked());
458
459 const QString codecId = cfg->getString("CodecId", "");
460
461 const int index = qMax(0, findIndexById(codecId, m_d->encoders));
462 ui->cmbCodec->setCurrentIndex(index);
463 slotCodecSelected(index);
464
465 slotH265ProfileChanged(ui->cmbProfileH265->currentIndex());
466}
467
469{
470 QStringList options;
471
472 if (currentCodecId() == "libopenh264") {
473 options << "-c:v" << "libopenh264";
474 options << "-b:v" << QString::number(ui->intOpenH264bitrate->value()) + "k";
475 } else if (currentCodecId() == "libx264") {
476 options << "-crf" << QString::number(ui->intCRFH264->value());
477
478 const int presetIndex = ui->cmbPresetH264->currentIndex();
479 options << "-preset" << m_d->presetsXH264[presetIndex].id();
480
481 const int profileIndex = ui->cmbProfileH264->currentIndex();
482 options << "-profile:v" << m_d->profilesXH264[profileIndex].id();
483
484 if (m_d->profilesXH264[profileIndex].id() == "high422") {
485 options << "-pix_fmt" << "yuv422p";
486 } else if (m_d->profilesXH264[profileIndex].id() == "high444") {
487 options << "-pix_fmt" << "yuv444p";
488 } else {
489 options << "-pix_fmt" << "yuv420p";
490 }
491
492 // Disabled! see the comment in c-tor!
493 //const int tuneIndex = ui->cmbTune->currentIndex();
494 //options << "-tune" << m_d->tunes[tuneIndex].id();
495
496 } else if (currentCodecId() == "libx265") {
497 const bool enableHDR =
498 ui->chkUseHDRMetadata->isEnabled() &&
499 ui->chkUseHDRMetadata->isChecked();
500
501 if (enableHDR) {
502 options << "-colorspace" << "bt2020nc"
503 << "-color_trc" << "smpte2084"
504 << "-color_primaries" << "bt2020";
505 }
506
507 options << "-c:v" << "libx265";
508 options << "-crf" << QString::number(ui->intCRFH265->value());
509
510 const int presetIndex = ui->cmbPresetH265->currentIndex();
511 options << "-preset" << m_d->presetsXH264[presetIndex].id();
512
513 const int profileIndex = ui->cmbProfileH265->currentIndex();
514 options << "-profile:v" << m_d->profilesXH265[profileIndex].id();
515
516 if (m_d->profilesXH265[profileIndex].id() == "main") {
517 options << "-pix_fmt" << "yuv420p";
518 } else if (m_d->profilesXH265[profileIndex].id() == "main10") {
519 options << "-pix_fmt" << "yuv420p10le";
520 } else {
521 KIS_SAFE_ASSERT_RECOVER_NOOP(0 && "Unknown profile selected for h265 encoder");
522 }
523
524 if (enableHDR) {
525 const QString metadataLine = m_d->hdrMetadataOptions.generateFFMpegOptions();
526 options << metadataLine.split(" ");
527 }
528
529 } else if (currentCodecId() == "libtheora") {
530 options << "-b" << QString::number(ui->intBitrate->value()) + "k";
531 } else if (currentCodecId() == "prores_ks") {
532 options << "-c:v" << "prores_ks"
533 << "-profile:v" << "4"
534 << "-pix_fmt" << "yuva444p10le";
535 } else if (currentCodecId() == "libvpx-vp9") {
536 options << "-c:v" << currentCodecId();
537 const bool preserveTransparency = (m_d->containerType == WEBM || m_d->containerType == MKV)
538 && ui->vp9PreserveTransparency->isChecked();
539 options << "-pix_fmt" << (preserveTransparency ? "yuva420p" : "yuv420p");
540 if (ui->vp9Lossless->isChecked()) {
541 options << "-lossless" << "1";
542 } else {
543 options << "-b:v" << QString::number(ui->vp9Mbits->value()) + "M";
544 }
545 } else if (currentCodecId() == "gif") {
546 const QString ditherFilterString = m_d->paletteDitherGIF[ ui->cmbPaletteuseDitherGIF->currentIndex() ].id();
547
548 options << "-f" << "gif"
549 << "-loop" << ( ui->gifLoop->isChecked() ? "0":"-1" )
550 << "-gifflags" << ( ui->gifTransDiff->isChecked() ? "+transdiff":"-transdiff" )
551 << "-palettegen" << QString("palettegen=stats_mode=%1%2")
552 .arg(m_d->paletteGenModeGIF[ ui->cmbPalettegenStatsModeGIF->currentIndex() ].id())
553 .arg(":reserve_transparent=" + QString(ui->gifReserveTransparent->isChecked() ? "1":"0"))
554 << "-lavfi" << QString("[0:v][1:v]paletteuse=dither=%1%2%3")
555 .arg(ditherFilterString)
556 .arg(ditherFilterString == "bayer" ? (QString(":bayer_scale=%1").arg(ui->intPaletteuseBayerScaleGIF->value()) ):"" )
557 .arg(":diff_mode=" + m_d->paletteDiffModeGIF[ ui->cmbPaletteuseDiffModeGIF->currentIndex() ].id() );
558
559 } else if (currentCodecId() == "apng") {
560 const int predIndex = ui->cmbPredAPNG->currentIndex();
561
562 options << "-f" << "apng"
563 << "-pred" << m_d->predAPNG[predIndex].id()
564 << "-plays" << ( ui->apngLoop->isChecked() ? "0":"1" );
565
566 } else if (currentCodecId() == "libwebp") {
567 const int presetIndex = ui->cmbPresetWEBP->currentIndex();
568
569 options << "-f" << "webp"
570 << "-lossless" << ( ui->webpLossless->isChecked() ? "1":"0" )
571 << "-compression_level" << QString::number(ui->intCompressWEBP->value())
572 << "-q:v" << QString::number(ui->intQscaleWEBP->value())
573 << "-preset" << m_d->presetsWEBP[presetIndex].id()
574 << "-loop" << ( ui->webpLoop->isChecked() ? "0":"1" );
575
576 }
577
578 return options;
579}
580
582{
583 return m_d->encoders[ui->cmbCodec->currentIndex()].id();
584}
585
587{
588 const bool enableHDR =
589 m_d->supportsHDR &&
590 index >= 0 &&
591 m_d->profilesXH265[index].id() == "main10";
592
593 ui->chkUseHDRMetadata->setEnabled(enableHDR);
594
595 QString hdrToolTip;
596
597 if (!m_d->supportsHDR) {
598 hdrToolTip = i18nc("@info:tooltip", "Exported animation format does not support HDR");
599 } else if (!enableHDR) {
600 hdrToolTip = i18nc("@info:tooltip", "HDR metadata available only with \"main10\" profile");
601 }
602
603 ui->chkUseHDRMetadata->setToolTip(hdrToolTip);
604}
605
607{
608 const bool enableBayer = m_d->paletteDitherGIF[ index ].id() == "bayer";
609 ui->lblPaletteuseBayerScaleGIF->setEnabled( enableBayer );
610 ui->intPaletteuseBayerScaleGIF->setEnabled( enableBayer );
611}
float value(const T *src, size_t ch)
int findIndexById(const QString &id, const QVector< KoID > &ids)
void populateComboWithKoIds(QComboBox *combo, const QVector< KoID > &ids, int defaultIndex)
KisPropertiesConfigurationSP configuration() const override
KisVideoExportOptionsDialog(ContainerType containerType, const QStringList &validEncoders, KisHDRMetadataOptions hdrOptions, QWidget *parent=0)
const QScopedPointer< Private > m_d
static ContainerType mimeToContainer(const QString &mimeType)
void setConfiguration(const KisPropertiesConfigurationSP config) override
static QVector< KoID > encoderIdentifiers(ContainerType type)
Ui::VideoExportOptionsDialog * ui
Definition KoID.h:30
QString id() const
Definition KoID.cpp:63
Encoder * encoder(Imf::OutputFile &file, const ExrPaintLayerSaveInfo &info, int width)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
auto mem_equal_to(MemTypeNoRef Class::*ptr, MemType &&value)
mem_equal_to is an unary functor that compares a member of the object to a given value
Definition KisMpl.h:233
Private(ContainerType _containerType, const QStringList &validEncoders)