Skip to content
Snippets Groups Projects
Commit f84be9e4 authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

media_encoder: print encoder name in logs

Refs #68788

Change-Id: Ib9d57ad5bdad7e10d30d11d3369fdf082eb1a999
parent b5b6862b
No related branches found
No related tags found
No related merge requests found
...@@ -482,11 +482,18 @@ void MediaEncoder::prepareEncoderContext(bool is_video) ...@@ -482,11 +482,18 @@ void MediaEncoder::prepareEncoderContext(bool is_video)
encoderCtx_ = avcodec_alloc_context3(outputEncoder_); encoderCtx_ = avcodec_alloc_context3(outputEncoder_);
#endif #endif
auto encoderName = encoderCtx_->av_class->item_name ?
encoderCtx_->av_class->item_name(encoderCtx_) : nullptr;
if (encoderName == nullptr)
encoderName = "encoder?";
// set some encoder settings here // set some encoder settings here
encoderCtx_->bit_rate = 1000 * atoi(av_dict_get(options_, "bitrate", encoderCtx_->bit_rate = 1000 * atoi(av_dict_get(options_, "bitrate",
NULL, 0)->value); NULL, 0)->value);
RING_DBG("Using bitrate %d", encoderCtx_->bit_rate); RING_DBG("[%s] Using bitrate %d", encoderName, encoderCtx_->bit_rate);
encoderCtx_->thread_count = std::thread::hardware_concurrency(); encoderCtx_->thread_count = std::thread::hardware_concurrency();
RING_DBG("[%s] Using %d threads", encoderName, encoderCtx_->thread_count);
if (is_video) { if (is_video) {
// resolution must be a multiple of two // resolution must be a multiple of two
...@@ -519,7 +526,7 @@ void MediaEncoder::prepareEncoderContext(bool is_video) ...@@ -519,7 +526,7 @@ void MediaEncoder::prepareEncoderContext(bool is_video)
encoderCtx_->sample_rate = atoi(v->value); encoderCtx_->sample_rate = atoi(v->value);
encoderCtx_->time_base = (AVRational) {1, encoderCtx_->sample_rate}; encoderCtx_->time_base = (AVRational) {1, encoderCtx_->sample_rate};
} else { } else {
RING_WARN("No sample rate set"); RING_WARN("[%s] No sample rate set", encoderName);
encoderCtx_->sample_rate = 8000; encoderCtx_->sample_rate = 8000;
} }
...@@ -527,12 +534,12 @@ void MediaEncoder::prepareEncoderContext(bool is_video) ...@@ -527,12 +534,12 @@ void MediaEncoder::prepareEncoderContext(bool is_video)
if (v) { if (v) {
auto c = std::atoi(v->value); auto c = std::atoi(v->value);
if (c > 2 or c < 1) { if (c > 2 or c < 1) {
RING_WARN("Clamping invalid channel value %d", c); RING_WARN("[%s] Clamping invalid channel value %d", encoderName, c);
c = 1; c = 1;
} }
encoderCtx_->channels = c; encoderCtx_->channels = c;
} else { } else {
RING_WARN("Channels not set"); RING_WARN("[%s] Channels not set", encoderName);
encoderCtx_->channels = 1; encoderCtx_->channels = 1;
} }
...@@ -541,9 +548,9 @@ void MediaEncoder::prepareEncoderContext(bool is_video) ...@@ -541,9 +548,9 @@ void MediaEncoder::prepareEncoderContext(bool is_video)
v = av_dict_get(options_, "frame_size", NULL, 0); v = av_dict_get(options_, "frame_size", NULL, 0);
if (v) { if (v) {
encoderCtx_->frame_size = atoi(v->value); encoderCtx_->frame_size = atoi(v->value);
RING_WARN("Frame size %d", encoderCtx_->frame_size); RING_WARN("[%s] Frame size %d", encoderName, encoderCtx_->frame_size);
} else { } else {
RING_WARN("Frame size not set"); RING_WARN("[%s] Frame size not set", encoderName);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment