export: allow users to override the thread count

This commit is contained in:
itsmattkc
2020-04-30 17:19:43 +10:00
parent aecfa842c3
commit ce42388d68
10 changed files with 141 additions and 15 deletions
+15 -4
View File
@@ -40,6 +40,7 @@ EncodingParams::EncodingParams() :
video_bit_rate_(0),
video_max_bit_rate_(0),
video_buffer_size_(0),
video_threads_(0),
audio_enabled_(false)
{
}
@@ -63,26 +64,31 @@ void EncodingParams::EnableAudio(const AudioRenderingParams &audio_params, const
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);
}
void EncodingParams::SetVideoBitRate(const int64_t &rate)
void EncodingParams::set_video_bit_rate(const int64_t &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;
}
void EncodingParams::SetVideoBufferSize(const int64_t &sz)
void EncodingParams::set_video_buffer_size(const int64_t &sz)
{
video_buffer_size_ = sz;
}
void EncodingParams::set_video_threads(const int &threads)
{
video_threads_ = threads;
}
const QString &EncodingParams::filename() const
{
return filename_;
@@ -123,6 +129,11 @@ const int64_t &EncodingParams::video_buffer_size() const
return video_buffer_size_;
}
const int &EncodingParams::video_threads() const
{
return video_threads_;
}
bool EncodingParams::audio_enabled() const
{
return audio_enabled_;
+7 -4
View File
@@ -43,10 +43,11 @@ public:
void EnableVideo(const VideoRenderingParams& video_params, const QString& vcodec);
void EnableAudio(const AudioRenderingParams& audio_params, const QString& acodec);
void SetVideoOption(const QString& key, const QString& value);
void SetVideoBitRate(const int64_t& rate);
void SetVideoMaxBitRate(const int64_t& rate);
void SetVideoBufferSize(const int64_t& sz);
void set_video_option(const QString& key, const QString& value);
void set_video_bit_rate(const int64_t& rate);
void set_video_max_bit_rate(const int64_t& rate);
void set_video_buffer_size(const int64_t& sz);
void set_video_threads(const int& threads);
const QString& filename() const;
@@ -57,6 +58,7 @@ public:
const int64_t& video_bit_rate() const;
const int64_t& video_max_bit_rate() const;
const int64_t& video_buffer_size() const;
const int& video_threads() const;
bool audio_enabled() const;
const QString& audio_codec() const;
@@ -75,6 +77,7 @@ private:
int64_t video_bit_rate_;
int64_t video_max_bit_rate_;
int64_t video_buffer_size_;
int video_threads_;
bool audio_enabled_;
QString audio_codec_;
+9 -1
View File
@@ -468,7 +468,15 @@ bool FFmpegEncoder::SetupCodecContext(AVStream* stream, AVCodecContext* codec_ct
}
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
error_code = avcodec_open2(codec_ctx, codec, &codec_opts);