exportdialog: allow restoring parameters
This commit is contained in:
@@ -82,4 +82,9 @@ void CineformSection::AddOpts(EncodingParams *params)
|
||||
params->set_video_option(QStringLiteral("quality"), QString::number(quality_combobox_->currentIndex()));
|
||||
}
|
||||
|
||||
void CineformSection::SetOpts(const EncodingParams *p)
|
||||
{
|
||||
quality_combobox_->setCurrentIndex(p->video_option(QStringLiteral("quality")).toInt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
|
||||
virtual void AddOpts(EncodingParams* params) override;
|
||||
|
||||
virtual void SetOpts(const EncodingParams *p) override;
|
||||
|
||||
private:
|
||||
QComboBox *quality_combobox_;
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
|
||||
virtual void AddOpts(EncodingParams* params){Q_UNUSED(params)}
|
||||
|
||||
virtual void SetOpts(const EncodingParams *p){Q_UNUSED(p)}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ H264Section::H264Section(int default_crf, QWidget *parent) :
|
||||
preset_combobox_->addItem(tr("Slow"));
|
||||
preset_combobox_->addItem(tr("Slower"));
|
||||
preset_combobox_->addItem(tr("Very Slow"));
|
||||
|
||||
|
||||
//Default to "medium"
|
||||
preset_combobox_->setCurrentIndex(5);
|
||||
|
||||
@@ -105,6 +105,10 @@ void H264Section::AddOpts(EncodingParams *params)
|
||||
|
||||
CompressionMethod method = static_cast<CompressionMethod>(compression_method_stack_->currentIndex());
|
||||
|
||||
// This option is not used by the encoder (nor is anything with the ove_ prefix), it's to help us
|
||||
// identify which option was chosen when params are restored
|
||||
params->set_video_option(QStringLiteral("ove_compressionmethod"), QString::number(method));
|
||||
|
||||
if (method == kConstantRateFactor) {
|
||||
|
||||
// Simply set CRF value
|
||||
@@ -121,9 +125,12 @@ void H264Section::AddOpts(EncodingParams *params)
|
||||
max_rate = bitrate_section_->GetMaximumBitRate();
|
||||
} else {
|
||||
// Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second)
|
||||
target_rate = qRound64(static_cast<double>(filesize_section_->GetFileSize()) / params->GetExportLength().toDouble());
|
||||
int64_t target_fs = filesize_section_->GetFileSize();
|
||||
target_rate = qRound64(static_cast<double>(target_fs) / params->GetExportLength().toDouble());
|
||||
min_rate = target_rate;
|
||||
max_rate = target_rate;
|
||||
|
||||
params->set_video_option(QStringLiteral("ove_targetfilesize"), QString::number(target_fs));
|
||||
}
|
||||
|
||||
// Disable CRF encoding
|
||||
@@ -135,10 +142,33 @@ void H264Section::AddOpts(EncodingParams *params)
|
||||
params->set_video_buffer_size(2000000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
params->set_video_option(QStringLiteral("preset"), QString::number(preset_combobox_->currentIndex()));
|
||||
}
|
||||
|
||||
void H264Section::SetOpts(const EncodingParams *p)
|
||||
{
|
||||
CompressionMethod method = static_cast<CompressionMethod>(p->video_option(QStringLiteral("ove_compressionmethod")).toInt());
|
||||
|
||||
compression_method_stack_->setCurrentIndex(method);
|
||||
|
||||
if (method == kConstantRateFactor) {
|
||||
crf_section_->SetValue(p->video_option(QStringLiteral("crf")).toInt());
|
||||
} else {
|
||||
int64_t target_rate = p->video_bit_rate();
|
||||
int64_t max_rate = p->video_max_bit_rate();
|
||||
|
||||
if (method == kTargetBitRate) {
|
||||
// Use user-supplied values for the bit rate
|
||||
bitrate_section_->SetTargetBitRate(target_rate);
|
||||
bitrate_section_->SetMaximumBitRate(max_rate);
|
||||
} else {
|
||||
// Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second)
|
||||
filesize_section_->SetFileSize(p->video_option(QStringLiteral("ove_targetfilesize")).toLongLong());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
H264CRFSection::H264CRFSection(int default_crf, QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
@@ -168,6 +198,11 @@ int H264CRFSection::GetValue() const
|
||||
return crf_slider_->value();
|
||||
}
|
||||
|
||||
void H264CRFSection::SetValue(int c)
|
||||
{
|
||||
crf_slider_->setValue(c);
|
||||
}
|
||||
|
||||
H264BitRateSection::H264BitRateSection(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
@@ -207,11 +242,21 @@ int64_t H264BitRateSection::GetTargetBitRate() const
|
||||
return qRound64(target_rate_->GetValue() * 1000000.0);
|
||||
}
|
||||
|
||||
void H264BitRateSection::SetTargetBitRate(int64_t b)
|
||||
{
|
||||
target_rate_->SetValue(double(b) * 0.000001);
|
||||
}
|
||||
|
||||
int64_t H264BitRateSection::GetMaximumBitRate() const
|
||||
{
|
||||
return qRound64(max_rate_->GetValue() * 1000000.0);
|
||||
}
|
||||
|
||||
void H264BitRateSection::SetMaximumBitRate(int64_t b)
|
||||
{
|
||||
max_rate_->SetValue(double(b) * 0.000001);
|
||||
}
|
||||
|
||||
H264FileSizeSection::H264FileSizeSection(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
@@ -243,6 +288,12 @@ int64_t H264FileSizeSection::GetFileSize() const
|
||||
return qRound64(file_size_->GetValue() * 1024.0 * 1024.0 * 8.0);
|
||||
}
|
||||
|
||||
void H264FileSizeSection::SetFileSize(int64_t f)
|
||||
{
|
||||
// Convert bits back to megabytes
|
||||
file_size_->SetValue(double(f) / 8.0 / 1024.0 / 1024.0);
|
||||
}
|
||||
|
||||
H265Section::H265Section(QWidget *parent) :
|
||||
H264Section(H264CRFSection::kDefaultH265CRF, parent)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
H264CRFSection(int default_crf, QWidget* parent = nullptr);
|
||||
|
||||
int GetValue() const;
|
||||
void SetValue(int c);
|
||||
|
||||
static const int kDefaultH264CRF = 18;
|
||||
static const int kDefaultH265CRF = 23;
|
||||
@@ -59,11 +60,13 @@ public:
|
||||
* @brief Get user-selected target bit rate (returns in BITS)
|
||||
*/
|
||||
int64_t GetTargetBitRate() const;
|
||||
void SetTargetBitRate(int64_t b);
|
||||
|
||||
/**
|
||||
* @brief Get user-selected maximum bit rate (returns in BITS)
|
||||
*/
|
||||
int64_t GetMaximumBitRate() const;
|
||||
void SetMaximumBitRate(int64_t b);
|
||||
|
||||
private:
|
||||
FloatSlider* target_rate_;
|
||||
@@ -82,6 +85,7 @@ public:
|
||||
* @brief Returns file size in BITS
|
||||
*/
|
||||
int64_t GetFileSize() const;
|
||||
void SetFileSize(int64_t f);
|
||||
|
||||
private:
|
||||
FloatSlider* file_size_;
|
||||
@@ -103,6 +107,8 @@ public:
|
||||
|
||||
virtual void AddOpts(EncodingParams* params) override;
|
||||
|
||||
virtual void SetOpts(const EncodingParams *p) override;
|
||||
|
||||
private:
|
||||
QStackedWidget* compression_method_stack_;
|
||||
|
||||
|
||||
@@ -39,6 +39,11 @@ public:
|
||||
return image_sequence_checkbox_->isChecked();
|
||||
}
|
||||
|
||||
void SetImageSequenceChecked(bool e)
|
||||
{
|
||||
image_sequence_checkbox_->setChecked(e);
|
||||
}
|
||||
|
||||
void SetTimebase(const rational& r)
|
||||
{
|
||||
frame_slider_->SetTimebase(r);
|
||||
|
||||
Reference in New Issue
Block a user