diff --git a/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp b/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp index 4b57ba6..6ee6285 100644 --- a/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp +++ b/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp @@ -580,3 +580,186 @@ MPVNoFBOBackend::handle_mpv_event(mpv_event* event) } } } + +QString +MPVNoFBOBackend::getStats() +{ + QString stats; + stats = + ""; + QString filename = getProperty("filename").toString(); + // File Info + stats += "File: " + filename; + stats += "
"; + QString title = getProperty("media-title").toString(); + if (title != filename) { + stats += "Title: " + title + "
"; + } + QString fileFormat = getProperty("file-format").toString(); + stats += "Format/Protocol: " + fileFormat + "
"; + QLocale a; + // a.formattedDataSize( + double cacheUsed = getProperty("cache-used").toDouble(); + // Utils::createTimestamp( + int demuxerSecs = getProperty("demuxer-cache-duration").toInt(); + QVariantMap demuxerState = getProperty("demuxer-cache-state").toMap(); + int demuxerCache = demuxerState.value("fw-bytes", QVariant(0)).toInt(); + + if (demuxerSecs + demuxerCache + cacheUsed > 0) { + QString cacheStats; + cacheStats += "Total Cache: "; + cacheStats += a.formattedDataSize(demuxerCache + cacheUsed); + cacheStats += " (Demuxer: "; + + cacheStats += a.formattedDataSize(demuxerCache); + cacheStats += ", "; + cacheStats += QString::number(demuxerSecs) + "s) "; + double cacheSpeed = getProperty("cache-speed").toDouble(); + if (cacheSpeed > 0) { + cacheStats += "Speed: "; + cacheStats += a.formattedDataSize(demuxerSecs); + cacheStats += "/s"; + } + cacheStats += "
"; + stats += cacheStats; + } + QString fileSize = + a.formattedDataSize(getProperty("file-size").toInt()).remove("-"); + stats += "Size: " + fileSize + "
"; + + stats += "
"; + // Video Info + QVariant videoParams = getProperty("video-params"); + if (videoParams.isNull()) { + videoParams = getProperty("video-out-params"); + } + if (!videoParams.isNull()) { + stats += "Video: " + getProperty("video-codec").toString(); + stats += "
"; + QString avsync = QString::number(getProperty("avsync").toDouble(), 'f', 3); + stats += "A-V: " + QString(avsync) + "
"; + + stats += "Dropped Frames: "; + int dFDC = getProperty("decoder-frame-drop-count").toInt(); + if (dFDC > 0) { + stats += QString::number(dFDC) + " (decoder) "; + } + int fDC = getProperty("frame-drop-count").toInt(); + if (fDC > 0) { + stats += QString::number(fDC) + " (output)"; + } + stats += "
"; + + int dFPS = getProperty("display-fps").toInt(); + int eDFPS = getProperty("estimated-display-fps").toInt(); + if ((dFPS + eDFPS) > 0) { + stats += "Display FPS: "; + + if (dFPS > 0) { + stats += QString::number(dFPS); + stats += " (specified) "; + } + if (eDFPS > 0) { + stats += QString::number(eDFPS); + stats += " (estimated)"; + } + stats += "
"; + } + + int cFPS = getProperty("container-fps").toInt(); + int eVFPS = getProperty("estimated-vf-fps").toInt(); + if ((cFPS + eVFPS) > 0) { + stats += "FPS: "; + + if (cFPS > 0) { + stats += QString::number(cFPS); + stats += " (specified) "; + } + if (eVFPS > 0) { + stats += QString::number(eVFPS); + stats += " (estimated)"; + } + stats += "
"; + } + QVariantMap vPM = videoParams.toMap(); + stats += "Native Resolution: "; + stats += vPM["w"].toString() + " x " + vPM["h"].toString(); + stats += "
"; + + stats += "Window Scale: "; + stats += vPM["window-scale"].toString(); + stats += "
"; + + stats += "Aspect Ratio: "; + stats += vPM["aspect"].toString(); + stats += "
"; + + stats += "Pixel Format: "; + stats += vPM["pixelformat"].toString(); + stats += "
"; + + stats += "Primaries: "; + stats += vPM["primaries"].toString(); + stats += " Colormatrix: "; + stats += vPM["colormatrix"].toString(); + stats += "
"; + + stats += "Levels: "; + stats += vPM["colorlevels"].toString(); + double sigPeak = vPM.value("sig-peak", QVariant(0.0)).toInt(); + if (sigPeak > 0) { + stats += " (HDR Peak: " + QString::number(sigPeak) + ")"; + } + stats += "
"; + + stats += "Gamma: "; + stats += vPM["gamma"].toString(); + stats += "
"; + + int pVB = getProperty("packet-video-bitrate").toInt(); + if (pVB > 0) { + stats += "Bitrate: "; + stats += a.formattedDataSize(pVB) + "/s"; + stats += "
"; + } + + stats += "
"; + } + QVariant audioParams = getProperty("audio-params"); + if (audioParams.isNull()) { + audioParams = getProperty("audio-out-params"); + } + if (!audioParams.isNull()) { + stats += "Audio: " + getProperty("audio-codec").toString(); + stats += "
"; + QVariantMap aPM = audioParams.toMap(); + + stats += "Format: "; + stats += aPM["format"].toString(); + stats += "
"; + + stats += "Sample Rate: "; + stats += aPM["samplerate"].toString() + " Hz"; + stats += "
"; + + stats += "Channels: "; + stats += aPM["chanel-count"].toString(); + stats += "
"; + + int pAB = getProperty("packet-audio-bitrate").toInt(); + if (pAB > 0) { + stats += "Bitrate: "; + stats += a.formattedDataSize(pAB) + "/s"; + stats += "
"; + } + + stats += "
"; + } + + return stats; +} + + diff --git a/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp b/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp index 7853bfa..a112a75 100644 --- a/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp +++ b/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp @@ -70,6 +70,7 @@ public slots: QVariant playerCommand(const Enums::Commands& command); void launchAboutQt(); void toggleOnTop(); + QString getStats(); // Optional but handy for MPV or custom backend settings. void command(const QVariant& params); void setProperty(const QString& name, const QVariant& value);