diff --git a/src/frame-writer.cpp b/src/frame-writer.cpp index a46d1e8..7bc8e2b 100644 --- a/src/frame-writer.cpp +++ b/src/frame-writer.cpp @@ -44,19 +44,35 @@ void FrameWriter::init_hw_accel() void FrameWriter::load_codec_options(AVDictionary **dict) { - static const std::map default_x264_options = { - {"tune", "zerolatency"}, - {"preset", "ultrafast"}, - {"crf", "20"}, + using CodecOptions = std::map; + + 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 default_codec_options = { + {"libx264", default_x264_options}, + {"libx265", default_x264_options}, + {"libvpx", default_libvpx_options}, + }; + + 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; } }