Skip to content
Snippets Groups Projects
Commit cff1bf40 authored by Pierre Lespagnol's avatar Pierre Lespagnol Committed by Adrien Béraud
Browse files

media/encoder: fix encoder.json CRF setting

"setDictValue" override "av_opt_set_int" settings. Always use av_opt_set_int to set CRF

Change-Id: I3a75773419901adf5d24d71bdbf5c571e6ab7178
parent 8fc78c4b
No related branches found
Tags android/release_346
No related merge requests found
...@@ -112,10 +112,6 @@ MediaEncoder::setOptions(const MediaDescription& args) ...@@ -112,10 +112,6 @@ MediaEncoder::setOptions(const MediaDescription& args)
"payload_type", args.payload_type, AV_OPT_SEARCH_CHILDREN)) < 0) "payload_type", args.payload_type, AV_OPT_SEARCH_CHILDREN)) < 0)
JAMI_ERR() << "Failed to set payload type: " << libav_utils::getError(ret); JAMI_ERR() << "Failed to set payload type: " << libav_utils::getError(ret);
// NOTE none of these are format options, and we don't have a codec context yet
libav_utils::setDictValue(&options_, "max_rate", std::to_string(args.codec->bitrate));
libav_utils::setDictValue(&options_, "crf", std::to_string(args.codec->quality));
if (not args.parameters.empty()) if (not args.parameters.empty())
libav_utils::setDictValue(&options_, "parameters", args.parameters); libav_utils::setDictValue(&options_, "parameters", args.parameters);
...@@ -802,7 +798,6 @@ MediaEncoder::initVP8(AVCodecContext* encoderCtx, uint64_t br) ...@@ -802,7 +798,6 @@ MediaEncoder::initVP8(AVCodecContext* encoderCtx, uint64_t br)
encoderCtx->qmin = 4; encoderCtx->qmin = 4;
encoderCtx->qmax = 56; encoderCtx->qmax = 56;
crf = std::min(encoderCtx->qmax, std::max((int)crf, encoderCtx->qmin)); crf = std::min(encoderCtx->qmax, std::max((int)crf, encoderCtx->qmin));
libav_utils::setDictValue(&options_, "crf", std::to_string(crf));
av_opt_set_int(encoderCtx, "crf", crf, AV_OPT_SEARCH_CHILDREN); av_opt_set_int(encoderCtx, "crf", crf, AV_OPT_SEARCH_CHILDREN);
encoderCtx->rc_buffer_size = bufSize; encoderCtx->rc_buffer_size = bufSize;
encoderCtx->rc_max_rate = maxBitrate; encoderCtx->rc_max_rate = maxBitrate;
...@@ -866,6 +861,7 @@ MediaEncoder::readConfig(AVCodecContext* encoderCtx) ...@@ -866,6 +861,7 @@ MediaEncoder::readConfig(AVCodecContext* encoderCtx)
std::string path = fileutils::get_config_dir() + DIR_SEPARATOR_STR + "encoder.json"; std::string path = fileutils::get_config_dir() + DIR_SEPARATOR_STR + "encoder.json";
std::string name = encoderCtx->codec->name; std::string name = encoderCtx->codec->name;
if (fileutils::isFile(path)) { if (fileutils::isFile(path)) {
JAMI_WARN("encoder.json file found, default settings will be erased");
try { try {
Json::Value root; Json::Value root;
std::ifstream file = fileutils::ifstream(path); std::ifstream file = fileutils::ifstream(path);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment