mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Update ffmpeg codec configures
This commit is contained in:
@@ -59,19 +59,23 @@ FFmpegVideoEncoder::~FFmpegVideoEncoder() {
|
||||
}
|
||||
|
||||
int FFmpegVideoEncoder::Init() {
|
||||
// av_log_set_level(AV_LOG_VERBOSE);
|
||||
av_log_set_level(AV_LOG_ERROR);
|
||||
|
||||
codec_ = avcodec_find_encoder(AV_CODEC_ID_H264);
|
||||
if (!codec_) {
|
||||
LOG_ERROR("Failed to find H.264 encoder");
|
||||
return -1;
|
||||
} else {
|
||||
if (0 == strcmp(codec_->name, "openh264")) {
|
||||
#ifdef __linux__
|
||||
if (0 != strcmp(codec_->name, "openh264")) {
|
||||
use_openh264_ = true;
|
||||
LOG_INFO("Use H264 encoder [OpenH264]");
|
||||
}
|
||||
#else
|
||||
LOG_INFO("Use H264 encoder [{}]", codec_->name);
|
||||
#endif
|
||||
}
|
||||
use_openh264_ = true;
|
||||
// use_openh264_ = true;
|
||||
|
||||
codec_ctx_ = avcodec_alloc_context3(codec_);
|
||||
if (!codec_ctx_) {
|
||||
@@ -93,10 +97,14 @@ int FFmpegVideoEncoder::Init() {
|
||||
codec_ctx_->gop_size = keyFrameInterval_;
|
||||
codec_ctx_->keyint_min = keyFrameInterval_;
|
||||
codec_ctx_->max_b_frames = 0;
|
||||
codec_ctx_->bit_rate = maxBitrate_ * 2500;
|
||||
codec_ctx_->bit_rate = maxBitrate_ * 2000;
|
||||
codec_ctx_->qmin = 15;
|
||||
codec_ctx_->qmax = 35;
|
||||
codec_ctx_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
codec_ctx_->flags2 |= AV_CODEC_FLAG2_LOCAL_HEADER;
|
||||
|
||||
av_opt_set_int(codec_ctx_->priv_data, "qp", 51, 0);
|
||||
av_opt_set_int(codec_ctx_->priv_data, "crf", 23, 0);
|
||||
// av_opt_set_int(codec_ctx_->priv_data, "qp", 51, 0);
|
||||
// av_opt_set_int(codec_ctx_->priv_data, "crf", 23, 0);
|
||||
|
||||
if (!use_openh264_) {
|
||||
av_opt_set(codec_ctx_->priv_data, "profile", "baseline", 0);
|
||||
|
||||
Reference in New Issue
Block a user