diff --git a/src/MediaFX/media_manager.cpp b/src/MediaFX/media_manager.cpp index a0e4a44..7ad7aba 100644 --- a/src/MediaFX/media_manager.cpp +++ b/src/MediaFX/media_manager.cpp @@ -10,6 +10,7 @@ using namespace std::chrono; MediaManager::MediaManager(const microseconds& frameDuration, QQuickView* quickView, QObject* parent) : QObject(parent) , m_frameDuration(frameDuration) + , m_currentRenderTime(Interval(0us, frameDuration)) , m_quickView(quickView) { connect(this, &MediaManager::finishEncoding, [this]() { this->finishedEncoding = true; }); @@ -32,6 +33,12 @@ void MediaManager::unregisterClip(MediaClip* clip) activeClips.removeOne(clip); } +void MediaManager::nextRenderTime() +{ + m_currentRenderTime = m_currentRenderTime.nextInterval(m_frameDuration); + emit currentRenderTimeChanged(); +} + void MediaManager::render() { for (auto clip : activeClips) { diff --git a/src/MediaFX/media_manager.h b/src/MediaFX/media_manager.h index baceed8..6a54d37 100644 --- a/src/MediaFX/media_manager.h +++ b/src/MediaFX/media_manager.h @@ -19,6 +19,7 @@ using namespace std::chrono; class MediaManager : public QObject { Q_OBJECT Q_PROPERTY(QQuickView* window READ window FINAL) + Q_PROPERTY(Interval currentRenderTime READ currentRenderTime NOTIFY currentRenderTimeChanged FINAL) public: using QObject::QObject; @@ -33,6 +34,8 @@ class MediaManager : public QObject { QQuickView* window() const { return m_quickView; }; const microseconds& frameDuration() { return m_frameDuration; }; + const Interval& currentRenderTime() const { return m_currentRenderTime; }; + void nextRenderTime(); void registerClip(MediaClip* clip); void unregisterClip(MediaClip* clip); @@ -43,10 +46,11 @@ class MediaManager : public QObject { signals: void finishEncoding(); - void frameRendered(); + void currentRenderTimeChanged(); private: microseconds m_frameDuration; + Interval m_currentRenderTime; QQuickView* m_quickView; QList activeClips; bool finishedEncoding = false; diff --git a/src/MediaFX/qml/sequence.js b/src/MediaFX/qml/sequence.js index 11ddd44..06ccad1 100644 --- a/src/MediaFX/qml/sequence.js +++ b/src/MediaFX/qml/sequence.js @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later function onClipEnded() { - MediaManager.frameRendered.connect(nextClip); + MediaManager.currentRenderTimeChanged.connect(nextClip); }; function onCurrentFrameTimechanged() { @@ -14,7 +14,7 @@ function onCurrentFrameTimechanged() { }; function nextClip() { - MediaManager.frameRendered.disconnect(nextClip); + MediaManager.currentRenderTimeChanged.disconnect(nextClip); if (internal.currentClipIndex + 1 < root.mediaClips.length) { var clip = root.mediaClips[internal.currentClipIndex]; clip.currentFrameTimeChanged.disconnect(onCurrentFrameTimechanged); diff --git a/src/MediaFX/session.cpp b/src/MediaFX/session.cpp index d0a66d4..def2ee7 100644 --- a/src/MediaFX/session.cpp +++ b/src/MediaFX/session.cpp @@ -114,14 +114,12 @@ bool Session::event(QEvent* event) void Session::render() { manager->render(); - auto frameData = renderControl->renderVideoFrame(); + manager->nextRenderTime(); if (encoder->write(encoder->videofd(), frameData.size(), frameData.constData()) == -1) return; - emit manager->frameRendered(); - if (manager->isFinishedEncoding()) { emit quickView->engine()->exit(0); return;