summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-07-25 16:33:20 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-08-01 10:36:03 +0000
commit5af58b7ee3e66155534f846922d7d3dbfdd5bffc (patch)
tree35bd8ed9855722445f59d0caf59c2a59ec4427de
parentfce3221189cf8b3a1b51cab916e2b4efa5de3fc8 (diff)
Fix odd resolution for encoder h264_mf
h264_mf get failed with odd resolution. We should investigate and include more codecs to the fix. Change-Id: I39482955f2e31f2d16d4add1a66f5e5d8c4afb46 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> (cherry picked from commit 32b1136869803e0404a5312a083d767c88831ef8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp b/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp
index 3c889f0d5..1deb71004 100644
--- a/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp
+++ b/src/plugins/multimedia/ffmpeg/qffmpegvideoframeencoder.cpp
@@ -49,8 +49,9 @@ bool VideoFrameEncoder::initCodec()
{
const auto qVideoCodec = d->settings.videoCodec();
const auto codecID = QFFmpegMediaFormatInfo::codecIdForVideoCodec(qVideoCodec);
+ const auto resolution = d->settings.videoResolution();
- std::tie(d->codec, d->accel) = findHwEncoder(codecID, d->settings.videoResolution());
+ std::tie(d->codec, d->accel) = findHwEncoder(codecID, resolution);
if (!d->codec)
d->codec = findSwEncoder(codecID, d->sourceSWFormat);
@@ -62,6 +63,19 @@ bool VideoFrameEncoder::initCodec()
qCDebug(qLcVideoFrameEncoder) << "found encoder" << d->codec->name << "for id" << d->codec->id;
+#ifdef Q_OS_WINDOWS
+ // TODO: investigate, there might be more encoders not supporting odd resolution
+ if (strcmp(d->codec->name, "h264_mf") == 0) {
+ auto makeEven = [](int size) { return size & ~1; };
+ const QSize fixedResolution(makeEven(resolution.width()), makeEven(resolution.height()));
+ if (fixedResolution != resolution) {
+ qCDebug(qLcVideoFrameEncoder) << "Fix odd video resolution for codec" << d->codec->name << ":"
+ << resolution << "->" << fixedResolution;
+ d->settings.setVideoResolution(fixedResolution);
+ }
+ }
+#endif
+
return true;
}