From 7d52dc19e3bd5e48a066e95669525cb9387afae4 Mon Sep 17 00:00:00 2001 From: Quackdoc <74831516+Quackdoc@users.noreply.github.com> Date: Fri, 4 Feb 2022 01:44:08 +0000 Subject: [PATCH] Add support for x264 and x265 presets (#1856) * Add support for x264 and x265 presets just adds presets for x264 and x265. seems to work fine for me. * UI tweaks Make the presets easier to understand, add tooltip explaining preset's effects * Do things properly, minor typo fix --- app/dialog/export/codec/h264section.cpp | 27 +++++++++++++++++++++++++ app/dialog/export/codec/h264section.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/app/dialog/export/codec/h264section.cpp b/app/dialog/export/codec/h264section.cpp index 101bf388f..6b15be526 100644 --- a/app/dialog/export/codec/h264section.cpp +++ b/app/dialog/export/codec/h264section.cpp @@ -42,6 +42,31 @@ H264Section::H264Section(int default_crf, QWidget *parent) : layout->setMargin(0); int row = 0; + layout->addWidget(new QLabel(tr("Encode Speed:")), row, 0); + + + preset_combobox_ = new QComboBox(); + preset_combobox_->setToolTip(tr("This setting allows you to tweak the ratio of export speed to compression quality. \n\n" + "If using Constant Rate Factor, slower speeds will result in smaller file sizes for the same quality. \n\n" + "If using Target Bit Rate or Target File Size, slower speeds will result in higher quality for the same bitrate/filesize. \n\n" + "This setting is equivalent to the `preset` setting in libx264.")); + + preset_combobox_->addItem(tr("Ultra Fast")); + preset_combobox_->addItem(tr("Super Fast")); + preset_combobox_->addItem(tr("Very Fast")); + preset_combobox_->addItem(tr("Faster")); + preset_combobox_->addItem(tr("Fast")); + preset_combobox_->addItem(tr("Medium")); + preset_combobox_->addItem(tr("Slow")); + preset_combobox_->addItem(tr("Slower")); + preset_combobox_->addItem(tr("Very Slow")); + + //Default to "medium" + preset_combobox_->setCurrentIndex(5); + + layout->addWidget(preset_combobox_, row, 1); + + row++; layout->addWidget(new QLabel(tr("Compression Method:")), row, 0); @@ -110,6 +135,8 @@ void H264Section::AddOpts(EncodingParams *params) params->set_video_buffer_size(2000000); } + + params->set_video_option(QStringLiteral("preset"), QString::number(preset_combobox_->currentIndex())); } H264CRFSection::H264CRFSection(int default_crf, QWidget *parent) : diff --git a/app/dialog/export/codec/h264section.h b/app/dialog/export/codec/h264section.h index 95f7fa84a..78fbef19a 100644 --- a/app/dialog/export/codec/h264section.h +++ b/app/dialog/export/codec/h264section.h @@ -23,6 +23,7 @@ #include #include +#include #include "codecsection.h" #include "widget/slider/floatslider.h" @@ -111,6 +112,7 @@ private: H264FileSizeSection* filesize_section_; + QComboBox *preset_combobox_; }; class H265Section : public H264Section