Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions src/frame-writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,35 @@ void FrameWriter::init_hw_accel()

void FrameWriter::load_codec_options(AVDictionary **dict)
{
static const std::map<std::string, std::string> default_x264_options = {
{"tune", "zerolatency"},
{"preset", "ultrafast"},
{"crf", "20"},
using CodecOptions = std::map<std::string, std::string>;

static const CodecOptions default_x264_options = {
{"tune", "zerolatency"},
{"preset", "ultrafast"},
{"crf", "20"},
};

static const CodecOptions default_libvpx_options = {
{"cpu-used", "5"},
{"deadline", "realtime"},
};

if (params.codec.find("libx264") != std::string::npos ||
params.codec.find("libx265") != std::string::npos)
static const std::map<std::string, const CodecOptions&> default_codec_options = {
{"libx264", default_x264_options},
{"libx265", default_x264_options},
{"libvpx", default_libvpx_options},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be also a line for libvpx-vp9?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a substring search so libvpx also matches libvpx-vp9.
The original code did that to avoid listing codec variants like libx264rgb and I preserved the behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense. Thanks for explaining.

};

for (const auto& opts : default_codec_options)
{
for (const auto& param : default_x264_options)
if (params.codec.find(opts.first) != std::string::npos)
{
if (!params.codec_options.count(param.first))
params.codec_options[param.first] = param.second;
for (const auto& param : opts.second)
{
if (!params.codec_options.count(param.first))
params.codec_options[param.first] = param.second;
}
break;
}
}

Expand Down