export: allow users to override the thread count
This commit is contained in:
+15
-4
@@ -40,6 +40,7 @@ EncodingParams::EncodingParams() :
|
|||||||
video_bit_rate_(0),
|
video_bit_rate_(0),
|
||||||
video_max_bit_rate_(0),
|
video_max_bit_rate_(0),
|
||||||
video_buffer_size_(0),
|
video_buffer_size_(0),
|
||||||
|
video_threads_(0),
|
||||||
audio_enabled_(false)
|
audio_enabled_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -63,26 +64,31 @@ void EncodingParams::EnableAudio(const AudioRenderingParams &audio_params, const
|
|||||||
audio_codec_ = acodec;
|
audio_codec_ = acodec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodingParams::SetVideoOption(const QString &key, const QString &value)
|
void EncodingParams::set_video_option(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
video_opts_.insert(key, value);
|
video_opts_.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodingParams::SetVideoBitRate(const int64_t &rate)
|
void EncodingParams::set_video_bit_rate(const int64_t &rate)
|
||||||
{
|
{
|
||||||
video_bit_rate_ = rate;
|
video_bit_rate_ = rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodingParams::SetVideoMaxBitRate(const int64_t &rate)
|
void EncodingParams::set_video_max_bit_rate(const int64_t &rate)
|
||||||
{
|
{
|
||||||
video_max_bit_rate_ = rate;
|
video_max_bit_rate_ = rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncodingParams::SetVideoBufferSize(const int64_t &sz)
|
void EncodingParams::set_video_buffer_size(const int64_t &sz)
|
||||||
{
|
{
|
||||||
video_buffer_size_ = sz;
|
video_buffer_size_ = sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EncodingParams::set_video_threads(const int &threads)
|
||||||
|
{
|
||||||
|
video_threads_ = threads;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &EncodingParams::filename() const
|
const QString &EncodingParams::filename() const
|
||||||
{
|
{
|
||||||
return filename_;
|
return filename_;
|
||||||
@@ -123,6 +129,11 @@ const int64_t &EncodingParams::video_buffer_size() const
|
|||||||
return video_buffer_size_;
|
return video_buffer_size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int &EncodingParams::video_threads() const
|
||||||
|
{
|
||||||
|
return video_threads_;
|
||||||
|
}
|
||||||
|
|
||||||
bool EncodingParams::audio_enabled() const
|
bool EncodingParams::audio_enabled() const
|
||||||
{
|
{
|
||||||
return audio_enabled_;
|
return audio_enabled_;
|
||||||
|
|||||||
+7
-4
@@ -43,10 +43,11 @@ public:
|
|||||||
void EnableVideo(const VideoRenderingParams& video_params, const QString& vcodec);
|
void EnableVideo(const VideoRenderingParams& video_params, const QString& vcodec);
|
||||||
void EnableAudio(const AudioRenderingParams& audio_params, const QString& acodec);
|
void EnableAudio(const AudioRenderingParams& audio_params, const QString& acodec);
|
||||||
|
|
||||||
void SetVideoOption(const QString& key, const QString& value);
|
void set_video_option(const QString& key, const QString& value);
|
||||||
void SetVideoBitRate(const int64_t& rate);
|
void set_video_bit_rate(const int64_t& rate);
|
||||||
void SetVideoMaxBitRate(const int64_t& rate);
|
void set_video_max_bit_rate(const int64_t& rate);
|
||||||
void SetVideoBufferSize(const int64_t& sz);
|
void set_video_buffer_size(const int64_t& sz);
|
||||||
|
void set_video_threads(const int& threads);
|
||||||
|
|
||||||
const QString& filename() const;
|
const QString& filename() const;
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ public:
|
|||||||
const int64_t& video_bit_rate() const;
|
const int64_t& video_bit_rate() const;
|
||||||
const int64_t& video_max_bit_rate() const;
|
const int64_t& video_max_bit_rate() const;
|
||||||
const int64_t& video_buffer_size() const;
|
const int64_t& video_buffer_size() const;
|
||||||
|
const int& video_threads() const;
|
||||||
|
|
||||||
bool audio_enabled() const;
|
bool audio_enabled() const;
|
||||||
const QString& audio_codec() const;
|
const QString& audio_codec() const;
|
||||||
@@ -75,6 +77,7 @@ private:
|
|||||||
int64_t video_bit_rate_;
|
int64_t video_bit_rate_;
|
||||||
int64_t video_max_bit_rate_;
|
int64_t video_max_bit_rate_;
|
||||||
int64_t video_buffer_size_;
|
int64_t video_buffer_size_;
|
||||||
|
int video_threads_;
|
||||||
|
|
||||||
bool audio_enabled_;
|
bool audio_enabled_;
|
||||||
QString audio_codec_;
|
QString audio_codec_;
|
||||||
|
|||||||
@@ -468,7 +468,15 @@ bool FFmpegEncoder::SetupCodecContext(AVStream* stream, AVCodecContext* codec_ct
|
|||||||
}
|
}
|
||||||
|
|
||||||
AVDictionary* codec_opts = nullptr;
|
AVDictionary* codec_opts = nullptr;
|
||||||
av_dict_set(&codec_opts, "threads", "auto", 0);
|
|
||||||
|
// Set thread count
|
||||||
|
if (params().video_threads() == 0) {
|
||||||
|
av_dict_set(&codec_opts, "threads", "auto", 0);
|
||||||
|
} else {
|
||||||
|
char thread_val[10];
|
||||||
|
sprintf_s(thread_val, 10, "%d", params().video_threads());
|
||||||
|
av_dict_set(&codec_opts, "threads", thread_val, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Try to open encoder
|
// Try to open encoder
|
||||||
error_code = avcodec_open2(codec_ctx, codec, &codec_opts);
|
error_code = avcodec_open2(codec_ctx, codec, &codec_opts);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ set(OLIVE_SOURCES
|
|||||||
${OLIVE_SOURCES}
|
${OLIVE_SOURCES}
|
||||||
dialog/export/export.h
|
dialog/export/export.h
|
||||||
dialog/export/export.cpp
|
dialog/export/export.cpp
|
||||||
|
dialog/export/exportadvancedvideodialog.h
|
||||||
|
dialog/export/exportadvancedvideodialog.cpp
|
||||||
dialog/export/exportaudiotab.h
|
dialog/export/exportaudiotab.h
|
||||||
dialog/export/exportaudiotab.cpp
|
dialog/export/exportaudiotab.cpp
|
||||||
dialog/export/exportcodec.h
|
dialog/export/exportcodec.h
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ void H264Section::AddOpts(EncodingParams *params)
|
|||||||
if (method == kConstantRateFactor) {
|
if (method == kConstantRateFactor) {
|
||||||
|
|
||||||
// Simply set CRF value
|
// Simply set CRF value
|
||||||
params->SetVideoOption(QStringLiteral("crf"), QString::number(crf_section_->GetValue()));
|
params->set_video_option(QStringLiteral("crf"), QString::number(crf_section_->GetValue()));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -95,11 +95,11 @@ void H264Section::AddOpts(EncodingParams *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disable CRF encoding
|
// Disable CRF encoding
|
||||||
params->SetVideoOption(QStringLiteral("crf"), QStringLiteral("-1"));
|
params->set_video_option(QStringLiteral("crf"), QStringLiteral("-1"));
|
||||||
|
|
||||||
params->SetVideoBitRate(target_rate);
|
params->set_video_bit_rate(target_rate);
|
||||||
params->SetVideoMaxBitRate(max_rate);
|
params->set_video_max_bit_rate(max_rate);
|
||||||
params->SetVideoBufferSize(2000000);
|
params->set_video_buffer_size(2000000);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -531,6 +531,8 @@ ExportParams ExportDialog::GenerateParams() const
|
|||||||
params.EnableVideo(video_render_params,
|
params.EnableVideo(video_render_params,
|
||||||
video_codec.id());
|
video_codec.id());
|
||||||
|
|
||||||
|
params.set_video_threads(video_tab_->threads());
|
||||||
|
|
||||||
video_tab_->GetCodecSection()->AddOpts(¶ms);
|
video_tab_->GetCodecSection()->AddOpts(¶ms);
|
||||||
|
|
||||||
params.set_color_transform(video_tab_->CurrentOCIOColorSpace());
|
params.set_color_transform(video_tab_->CurrentOCIOColorSpace());
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#include "exportadvancedvideodialog.h"
|
||||||
|
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
|
ExportAdvancedVideoDialog::ExportAdvancedVideoDialog(QWidget *parent) :
|
||||||
|
QDialog(parent)
|
||||||
|
{
|
||||||
|
setWindowTitle(tr("Advanced"));
|
||||||
|
|
||||||
|
QGridLayout* layout = new QGridLayout(this);
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
layout->addWidget(new QLabel(tr("Threads:")), row, 0);
|
||||||
|
|
||||||
|
thread_slider_ = new IntegerSlider();
|
||||||
|
thread_slider_->SetMinimum(0);
|
||||||
|
layout->addWidget(thread_slider_, row, 1);
|
||||||
|
|
||||||
|
row++;
|
||||||
|
|
||||||
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
connect(buttons, &QDialogButtonBox::accepted, this, &ExportAdvancedVideoDialog::accept);
|
||||||
|
connect(buttons, &QDialogButtonBox::rejected, this, &ExportAdvancedVideoDialog::reject);
|
||||||
|
layout->addWidget(buttons, row, 0, 1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ExportAdvancedVideoDialog::threads() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(thread_slider_->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExportAdvancedVideoDialog::set_threads(int t)
|
||||||
|
{
|
||||||
|
thread_slider_->SetValue(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_EXIT
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef EXPORTADVANCEDVIDEODIALOG_H
|
||||||
|
#define EXPORTADVANCEDVIDEODIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "render/backend/exportparams.h"
|
||||||
|
#include "widget/slider/integerslider.h"
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_ENTER
|
||||||
|
|
||||||
|
class ExportAdvancedVideoDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ExportAdvancedVideoDialog(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
int threads() const;
|
||||||
|
void set_threads(int t);
|
||||||
|
|
||||||
|
private:
|
||||||
|
IntegerSlider* thread_slider_;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
OLIVE_NAMESPACE_EXIT
|
||||||
|
|
||||||
|
#endif // EXPORTADVANCEDVIDEODIALOG_H
|
||||||
@@ -24,8 +24,10 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
#include "exportadvancedvideodialog.h"
|
||||||
#include "render/backend/exportparams.h"
|
#include "render/backend/exportparams.h"
|
||||||
#include "render/colormanager.h"
|
#include "render/colormanager.h"
|
||||||
|
|
||||||
@@ -33,7 +35,8 @@ OLIVE_NAMESPACE_ENTER
|
|||||||
|
|
||||||
ExportVideoTab::ExportVideoTab(ColorManager* color_manager, QWidget *parent) :
|
ExportVideoTab::ExportVideoTab(ColorManager* color_manager, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
color_manager_(color_manager)
|
color_manager_(color_manager),
|
||||||
|
threads_(0)
|
||||||
{
|
{
|
||||||
QVBoxLayout* outer_layout = new QVBoxLayout(this);
|
QVBoxLayout* outer_layout = new QVBoxLayout(this);
|
||||||
|
|
||||||
@@ -106,6 +109,11 @@ H264Section *ExportVideoTab::h264_section() const
|
|||||||
return h264_section_;
|
return h264_section_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int &ExportVideoTab::threads() const
|
||||||
|
{
|
||||||
|
return threads_;
|
||||||
|
}
|
||||||
|
|
||||||
QWidget* ExportVideoTab::SetupResolutionSection()
|
QWidget* ExportVideoTab::SetupResolutionSection()
|
||||||
{
|
{
|
||||||
int row = 0;
|
int row = 0;
|
||||||
@@ -196,6 +204,12 @@ QWidget *ExportVideoTab::SetupCodecSection()
|
|||||||
h264_section_ = new H264Section();
|
h264_section_ = new H264Section();
|
||||||
codec_stack_->addWidget(h264_section_);
|
codec_stack_->addWidget(h264_section_);
|
||||||
|
|
||||||
|
row++;
|
||||||
|
|
||||||
|
QPushButton* advanced_btn = new QPushButton(tr("Advanced"));
|
||||||
|
connect(advanced_btn, &QPushButton::clicked, this, &ExportVideoTab::OpenAdvancedDialog);
|
||||||
|
codec_layout->addWidget(advanced_btn, row, 1);
|
||||||
|
|
||||||
return codec_group;
|
return codec_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,4 +218,15 @@ void ExportVideoTab::MaintainAspectRatioChanged(bool val)
|
|||||||
scaling_method_combobox_->setEnabled(!val);
|
scaling_method_combobox_->setEnabled(!val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExportVideoTab::OpenAdvancedDialog()
|
||||||
|
{
|
||||||
|
ExportAdvancedVideoDialog d(this);
|
||||||
|
|
||||||
|
d.set_threads(threads_);
|
||||||
|
|
||||||
|
if (d.exec() == QDialog::Accepted) {
|
||||||
|
threads_ = d.threads();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OLIVE_NAMESPACE_EXIT
|
OLIVE_NAMESPACE_EXIT
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ public:
|
|||||||
ImageSection* image_section() const;
|
ImageSection* image_section() const;
|
||||||
H264Section* h264_section() const;
|
H264Section* h264_section() const;
|
||||||
|
|
||||||
|
const int& threads() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ColorSpaceChanged(const QString& colorspace);
|
void ColorSpaceChanged(const QString& colorspace);
|
||||||
|
|
||||||
@@ -83,9 +85,13 @@ private:
|
|||||||
|
|
||||||
ColorManager* color_manager_;
|
ColorManager* color_manager_;
|
||||||
|
|
||||||
|
int threads_;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void MaintainAspectRatioChanged(bool val);
|
void MaintainAspectRatioChanged(bool val);
|
||||||
|
|
||||||
|
void OpenAdvancedDialog();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
OLIVE_NAMESPACE_EXIT
|
OLIVE_NAMESPACE_EXIT
|
||||||
|
|||||||
Reference in New Issue
Block a user