diff --git a/autotests/ffmpegextractortest.cpp b/autotests/ffmpegextractortest.cpp --- a/autotests/ffmpegextractortest.cpp +++ b/autotests/ffmpegextractortest.cpp @@ -48,6 +48,7 @@ QCOMPARE(result.properties().value(Property::Width).toInt(), 1280); QCOMPARE(result.properties().value(Property::Height).toInt(), 720); + QCOMPARE(result.properties().value(Property::FrameRate).toDouble(), 24.0/1.001); } QTEST_GUILESS_MAIN(ffmpegExtractorTest) diff --git a/autotests/propertyinfotest.cpp b/autotests/propertyinfotest.cpp --- a/autotests/propertyinfotest.cpp +++ b/autotests/propertyinfotest.cpp @@ -94,6 +94,7 @@ PropertyInfo framerate(Property::FrameRate); QCOMPARE(framerate.formatAsDisplayString(QVariant(23)), QStringLiteral("23 fps")); + QCOMPARE(framerate.formatAsDisplayString(QVariant(23.976)), QStringLiteral("23.98 fps")); } QTEST_GUILESS_MAIN(PropertyInfoTest) diff --git a/src/extractors/ffmpegextractor.cpp b/src/extractors/ffmpegextractor.cpp --- a/src/extractors/ffmpegextractor.cpp +++ b/src/extractors/ffmpegextractor.cpp @@ -95,7 +95,7 @@ result->add(Property::BitRate, bitrate); for (uint i = 0; i < fmt_ctx->nb_streams; i++) { - const AVStream* stream = fmt_ctx->streams[i]; + AVStream* stream = fmt_ctx->streams[i]; #if defined HAVE_AVSTREAM_CODECPAR && HAVE_AVSTREAM_CODECPAR const AVCodecParameters* codec = stream->codecpar; #else @@ -112,9 +112,10 @@ if (aspectRatio) result->add(Property::AspectRatio, aspectRatio); - int frameRate = stream->avg_frame_rate.num; - if (stream->avg_frame_rate.den) - frameRate /= stream->avg_frame_rate.den; + AVRational avFrameRate = av_guess_frame_rate(fmt_ctx, stream, NULL); + double frameRate = avFrameRate.num; + if (avFrameRate.den) + frameRate /= avFrameRate.den; if (frameRate) result->add(Property::FrameRate, frameRate); } diff --git a/src/formatstrings.cpp b/src/formatstrings.cpp --- a/src/formatstrings.cpp +++ b/src/formatstrings.cpp @@ -149,5 +149,5 @@ QString FormatStrings::formatAsFrameRate(const QVariant& value) { - return QString(value.toString() + i18nc("Symbol of frames per second, with space", " fps")); + return i18nc("Symbol of frames per second, with space", "%1 fps", round(value.toDouble() * 100) / 100); } diff --git a/src/propertyinfo.cpp b/src/propertyinfo.cpp --- a/src/propertyinfo.cpp +++ b/src/propertyinfo.cpp @@ -143,7 +143,7 @@ case Property::FrameRate: d->name = QStringLiteral("frameRate"); d->displayName = i18nc("@label", "Frame Rate"); - d->valueType = QVariant::Int; + d->valueType = QVariant::Double; d->formatAsString = &FormatStrings::formatAsFrameRate; break;