From 554c2d1ce52deb2d420f373f9374d5c27b2b5f04 Mon Sep 17 00:00:00 2001 From: KirbysDarkNebula <65826675+KirbysDarkNebula@users.noreply.github.com> Date: Fri, 29 Nov 2024 00:41:34 +0100 Subject: [PATCH 1/2] Fix video framerate being synced to scene framerate Initial fix --- src/core/Boxes/videobox.cpp | 1 + src/core/Boxes/videobox.h | 24 +++++++++++++++++++ .../FileCacheHandlers/videocachehandler.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/core/Boxes/videobox.cpp b/src/core/Boxes/videobox.cpp index 51dd53366..14994bcc6 100644 --- a/src/core/Boxes/videobox.cpp +++ b/src/core/Boxes/videobox.cpp @@ -66,6 +66,7 @@ VideoBox::VideoBox() : AnimationBox("Video", eBoxType::video), connect(this, &eBoxOrSound::parentChanged, mSound.get(), &eBoxOrSound::setParentGroup); + connect(this, &eBoxOrSound::parentChanged, this, &VideoBox::setCorrectFps); } void VideoBox::fileHandlerConnector(ConnContext &conn, VideoFileHandler *obj) { diff --git a/src/core/Boxes/videobox.h b/src/core/Boxes/videobox.h index da39e454d..d160107dc 100644 --- a/src/core/Boxes/videobox.h +++ b/src/core/Boxes/videobox.h @@ -29,7 +29,9 @@ #include #include "Boxes/animationbox.h" #include "FileCacheHandlers/videocachehandler.h" +#include "canvas.h" +#include class eVideoSound; class CORE_EXPORT VideoBox : public AnimationBox { @@ -66,6 +68,28 @@ class CORE_EXPORT VideoBox : public AnimationBox { qsptr mSound; FileHandlerObjRef mFileHandler; + + void setCorrectFps(){ + auto const pScene = getParentScene(); + if (!pScene) { return; } + + auto const dataHandler = mFileHandler->getFrameHandler(); + if (!dataHandler) { return; } + dataHandler->mFrameHandlers.length(); + qsptr vframeHandler; + vframeHandler = enve::make_shared(dataHandler); + + // Any changes we make to the video in the timeline have to be reflected on the video stream, that's why we have to apply the changes to dataHandler and vframeHandler. + qreal newmod = (pScene->getFps() / dataHandler->getFps()); + dataHandler->setFps(dataHandler->getFps() *newmod); + vframeHandler->mVideoStreamsData->fFps = dataHandler->getFps(); + dataHandler->setFrameCount(vframeHandler->mVideoStreamsData->fFrameCount*newmod); + vframeHandler->mVideoStreamsData->fFrameCount = vframeHandler->mVideoStreamsData->fFrameCount*newmod; + setAnimationFramesHandler(vframeHandler); + animationDataChanged(); + return; + } + }; #endif // VIDEOBOX_H diff --git a/src/core/FileCacheHandlers/videocachehandler.h b/src/core/FileCacheHandlers/videocachehandler.h index ae9c06911..9db16164e 100644 --- a/src/core/FileCacheHandlers/videocachehandler.h +++ b/src/core/FileCacheHandlers/videocachehandler.h @@ -66,6 +66,7 @@ class CORE_EXPORT VideoDataHandler : public FileDataCacheHandler { qreal mFrameFps = 0; int mFrameWidth = 0; int mFrameHeight = 0; +public: QList mFrameHandlers; QList mFramesBeingLoaded; QList> mFrameLoaders; @@ -103,6 +104,7 @@ class CORE_EXPORT VideoFrameHandler : public AnimationFrameHandler { std::set mNeededFrames; VideoDataHandler* const mDataHandler; +public: stdsptr mVideoStreamsData; }; #include "CacheHandlers/soundcachehandler.h" From d0ddbb71f6a95d80a5fd45581dda8d50ab907dd1 Mon Sep 17 00:00:00 2001 From: KirbysDarkNebula <65826675+KirbysDarkNebula@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:44:24 +0100 Subject: [PATCH 2/2] Update videobox.h Removed unnecessary lines of code --- src/core/Boxes/videobox.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/Boxes/videobox.h b/src/core/Boxes/videobox.h index d160107dc..d74ce1d81 100644 --- a/src/core/Boxes/videobox.h +++ b/src/core/Boxes/videobox.h @@ -31,7 +31,6 @@ #include "FileCacheHandlers/videocachehandler.h" #include "canvas.h" -#include class eVideoSound; class CORE_EXPORT VideoBox : public AnimationBox { @@ -75,7 +74,6 @@ class CORE_EXPORT VideoBox : public AnimationBox { auto const dataHandler = mFileHandler->getFrameHandler(); if (!dataHandler) { return; } - dataHandler->mFrameHandlers.length(); qsptr vframeHandler; vframeHandler = enve::make_shared(dataHandler);