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..d74ce1d81 100644 --- a/src/core/Boxes/videobox.h +++ b/src/core/Boxes/videobox.h @@ -29,6 +29,7 @@ #include #include "Boxes/animationbox.h" #include "FileCacheHandlers/videocachehandler.h" +#include "canvas.h" class eVideoSound; @@ -66,6 +67,27 @@ 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; } + 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"