encoder/exportdialog: add compression options for H264 exporting
This commit is contained in:
@@ -15,6 +15,9 @@ const EncodingParams &Encoder::params() const
|
||||
|
||||
EncodingParams::EncodingParams() :
|
||||
video_enabled_(false),
|
||||
video_bit_rate_(0),
|
||||
video_max_bit_rate_(0),
|
||||
video_buffer_size_(0),
|
||||
audio_enabled_(false)
|
||||
{
|
||||
}
|
||||
@@ -38,6 +41,26 @@ void EncodingParams::EnableAudio(const AudioRenderingParams &audio_params, const
|
||||
audio_codec_ = acodec;
|
||||
}
|
||||
|
||||
void EncodingParams::SetVideoOption(const QString &key, const QString &value)
|
||||
{
|
||||
video_opts_.insert(key, value);
|
||||
}
|
||||
|
||||
void EncodingParams::SetVideoBitRate(const int64_t &rate)
|
||||
{
|
||||
video_bit_rate_ = rate;
|
||||
}
|
||||
|
||||
void EncodingParams::SetVideoMaxBitRate(const int64_t &rate)
|
||||
{
|
||||
video_max_bit_rate_ = rate;
|
||||
}
|
||||
|
||||
void EncodingParams::SetVideoBufferSize(const int64_t &sz)
|
||||
{
|
||||
video_buffer_size_ = sz;
|
||||
}
|
||||
|
||||
const QString &EncodingParams::filename() const
|
||||
{
|
||||
return filename_;
|
||||
@@ -58,6 +81,26 @@ const VideoRenderingParams &EncodingParams::video_params() const
|
||||
return video_params_;
|
||||
}
|
||||
|
||||
const QHash<QString, QString> &EncodingParams::video_opts() const
|
||||
{
|
||||
return video_opts_;
|
||||
}
|
||||
|
||||
const int64_t &EncodingParams::video_bit_rate() const
|
||||
{
|
||||
return video_bit_rate_;
|
||||
}
|
||||
|
||||
const int64_t &EncodingParams::video_max_bit_rate() const
|
||||
{
|
||||
return video_max_bit_rate_;
|
||||
}
|
||||
|
||||
const int64_t &EncodingParams::video_buffer_size() const
|
||||
{
|
||||
return video_buffer_size_;
|
||||
}
|
||||
|
||||
bool EncodingParams::audio_enabled() const
|
||||
{
|
||||
return audio_enabled_;
|
||||
@@ -73,6 +116,16 @@ const AudioRenderingParams &EncodingParams::audio_params() const
|
||||
return audio_params_;
|
||||
}
|
||||
|
||||
const rational &EncodingParams::GetExportLength() const
|
||||
{
|
||||
return export_length_;
|
||||
}
|
||||
|
||||
void EncodingParams::SetExportLength(const rational &export_length)
|
||||
{
|
||||
export_length_ = export_length;
|
||||
}
|
||||
|
||||
Encoder* Encoder::CreateFromID(const QString &id, const EncodingParams& params)
|
||||
{
|
||||
Q_UNUSED(id)
|
||||
|
||||
@@ -17,29 +17,49 @@ public:
|
||||
EncodingParams();
|
||||
|
||||
void SetFilename(const QString& filename);
|
||||
|
||||
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);
|
||||
|
||||
const QString& filename() const;
|
||||
|
||||
bool video_enabled() const;
|
||||
const QString& video_codec() const;
|
||||
const VideoRenderingParams& video_params() const;
|
||||
const QHash<QString, QString>& video_opts() const;
|
||||
const int64_t& video_bit_rate() const;
|
||||
const int64_t& video_max_bit_rate() const;
|
||||
const int64_t& video_buffer_size() const;
|
||||
|
||||
bool audio_enabled() const;
|
||||
const QString& audio_codec() const;
|
||||
const AudioRenderingParams& audio_params() const;
|
||||
|
||||
const rational& GetExportLength() const;
|
||||
void SetExportLength(const rational& GetExportLength);
|
||||
|
||||
private:
|
||||
QString filename_;
|
||||
|
||||
bool video_enabled_;
|
||||
QString video_codec_;
|
||||
VideoRenderingParams video_params_;
|
||||
QHash<QString, QString> video_opts_;
|
||||
int64_t video_bit_rate_;
|
||||
int64_t video_max_bit_rate_;
|
||||
int64_t video_buffer_size_;
|
||||
|
||||
bool audio_enabled_;
|
||||
QString audio_codec_;
|
||||
AudioRenderingParams audio_params_;
|
||||
|
||||
rational export_length_;
|
||||
|
||||
};
|
||||
|
||||
class Encoder : public QObject
|
||||
|
||||
@@ -337,6 +337,28 @@ bool FFmpegEncoder::InitializeStream(AVMediaType type, AVStream** stream_ptr, AV
|
||||
|
||||
// FIXME: Make this customizable again
|
||||
codec_ctx->pix_fmt = encoder->pix_fmts[0];
|
||||
|
||||
// Set custom options
|
||||
{
|
||||
QHash<QString, QString>::const_iterator i;
|
||||
|
||||
for (i=params().video_opts().begin();i!=params().video_opts().end();i++) {
|
||||
av_opt_set(video_codec_ctx_->priv_data, i.key().toUtf8(), i.value().toUtf8(), AV_OPT_SEARCH_CHILDREN);
|
||||
}
|
||||
|
||||
if (params().video_bit_rate() > 0) {
|
||||
video_codec_ctx_->bit_rate = params().video_bit_rate();
|
||||
}
|
||||
|
||||
if (params().video_max_bit_rate() > 0) {
|
||||
video_codec_ctx_->rc_max_rate = params().video_max_bit_rate();
|
||||
}
|
||||
|
||||
if (params().video_buffer_size() > 0) {
|
||||
video_codec_ctx_->rc_buffer_size = params().video_buffer_size();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
codec_ctx->sample_rate = params().audio_params().sample_rate();
|
||||
codec_ctx->channel_layout = params().audio_params().channel_layout();
|
||||
|
||||
@@ -5,6 +5,7 @@ extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libswscale/swscale.h>
|
||||
#include <libswresample/swresample.h>
|
||||
#include <libavutil/opt.h>
|
||||
}
|
||||
|
||||
#include "codec/encoder.h"
|
||||
|
||||
Reference in New Issue
Block a user