Browse Source

Log converted encoder input detail alongside HEVC quantization

stream-multiview
evgeny 6 days ago
parent
commit
d1ba26f8ac
  1. 3
      src/video/video.c
  2. 16
      tools/chatgui/src/live_video_encoder.cpp
  3. 7
      tools/chatgui/tests/test_stream_publish.cpp

3
src/video/video.c

@ -103,8 +103,7 @@ static void video_av_log_cb(void* avcl, int level, const char* fmt, va_list vl)
&& (strstr(buf, "::SubmitInput() : format") || strstr(buf, "SubmitToEncoder() End: frame pts=")
|| strstr(buf, "::QueryOutput()") || strstr(buf, "QueryOutput() End: frame pts="))) return;
DEBUG_TRACE(DEBUG_CATEGORY_DEBUG, "ffmpeg AMF encoder=%s: %s", encoder, buf);
}
else if (level <= AV_LOG_ERROR) DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "ffmpeg: %s", buf);
} else if (level <= AV_LOG_ERROR) DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "ffmpeg: %s", buf);
else DEBUG_WARN(DEBUG_CATEGORY_VIDEO, "ffmpeg: %s", buf);
}

16
tools/chatgui/src/live_video_encoder.cpp

@ -390,6 +390,22 @@ bool LiveVideoEncoder::encode(const QImage& image, uint64_t pts, bool key, QList
int stride[4] = {static_cast<int>(canvas.bytesPerLine()), 0, 0, 0};
result = sws_scale(m->scale, input, stride, 0, canvas.height(), m->frame->data, m->frame->linesize);
}
if (result >= 0 && m->reportTimer.elapsed() >= 1000 && debug_should_output(DEBUG_LEVEL_TRACE, DEBUG_CATEGORY_DEBUG)
&& (m->frame->format == AV_PIX_FMT_NV12 || m->frame->format == AV_PIX_FMT_YUV420P)) {
uint64_t edges = 0, samples = 0;
int minimum = 255, maximum = 0;
for (int y = 0; y + 1 < m->frame->height; y += 16) {
const uint8_t* row = m->frame->data[0] + y * m->frame->linesize[0];
for (int x = 0; x + 1 < m->frame->width; x += 16) {
int value = row[x]; minimum = std::min(minimum, value); maximum = std::max(maximum, value);
edges += std::abs(value - row[x + 1]) + std::abs(value - row[x + m->frame->linesize[0]]); samples += 2;
}
}
DEBUG_TRACE(DEBUG_CATEGORY_DEBUG,
"video encoder input name=%s pts=%llu source=%dx%d encoded=%dx%d pixel=%d luma_min=%d luma_max=%d edge_x1000=%llu",
qPrintable(m->name), (unsigned long long)pts, image.width(), image.height(), m->frame->width, m->frame->height,
m->frame->format, minimum, maximum, (unsigned long long)(samples ? edges * 1000 / samples : 0));
}
bool constrained = m->config.profile != LiveVideoProfile::Automatic;
if (constrained && m->timestamps.size() >= 8) {
m->error = "GPU encoder exceeded the bounded input pipeline";

7
tools/chatgui/tests/test_stream_publish.cpp

@ -210,6 +210,9 @@ private slots:
av_log(context, AV_LOG_DEBUG, "UTUN_AMF_LOG_TEST driver value=%d\n", 17);
QCOMPARE(ffmpegDiagnosticMessages.size(), 1);
QVERIFY(ffmpegDiagnosticMessages.front().contains("encoder=hevc_amf: UTUN_AMF_LOG_TEST driver value=17"));
av_log(context, AV_LOG_DEBUG, "UTUN_AMF_LOG_TEST Debug: AMFEncoderUVEHEVCImpl::QueryOutput()\n");
av_log(context, AV_LOG_DEBUG, "UTUN_AMF_LOG_TEST Trace: SubmitToEncoder() End: frame pts=17\n");
QCOMPARE(ffmpegDiagnosticMessages.size(), 1);
codec.name = "libx264";
av_log(context, AV_LOG_DEBUG, "UTUN_AMF_LOG_TEST unrelated encoder\n");
av_log(nullptr, AV_LOG_DEBUG, "UTUN_AMF_LOG_TEST unrelated context\n");
@ -220,6 +223,10 @@ private slots:
av_log(nullptr, AV_LOG_ERROR, "UTUN_AMF_LOG_TEST normal error\n");
QCOMPARE(ffmpegDiagnosticMessages.size(), 2);
QVERIFY(ffmpegDiagnosticMessages.back().contains("normal error"));
debug_set_category_level(DEBUG_CATEGORY_DEBUG, DEBUG_LEVEL_TRACE);
av_log(context, AV_LOG_DEBUG, "UTUN_AMF_LOG_TEST Warning: AMFEncoderUVEHEVCImpl::QueryOutput() failed\n");
QCOMPARE(ffmpegDiagnosticMessages.size(), 3);
QVERIFY(ffmpegDiagnosticMessages.back().contains("Warning:"));
#else
QSKIP("FFmpeg unavailable");
#endif

Loading…
Cancel
Save