From 216a156d67ebb94828ecc13e7c7ef87dd405cf44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= <ole.andre.rodlie@gmail.com> Date: Fri, 19 Jul 2024 19:34:46 +0200 Subject: [PATCH] Video spec changes Also add some checks and more info in 'handleNewVideoClip'. --- src/app/GUI/mainwindow.cpp | 29 +++++++++++++++++++++++++---- src/core/Boxes/videobox.cpp | 6 +++--- src/core/Boxes/videobox.h | 5 ++--- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/app/GUI/mainwindow.cpp b/src/app/GUI/mainwindow.cpp index 173841a85..d12eb1e40 100644 --- a/src/app/GUI/mainwindow.cpp +++ b/src/app/GUI/mainwindow.cpp @@ -2076,14 +2076,35 @@ void MainWindow::writeRecentFiles() void MainWindow::handleNewVideoClip(const VideoBox::VideoSpecs &specs) { + if (specs.fps < 1 || specs.dim.height() < 1 || specs.dim.width() < 1) { return; } + const auto scene = *mDocument.fActiveScene; if (!scene) { return; } + + // only continue if this is the only clip if (scene->getContainedBoxes().count() != 1) { return; } + + // is identical? + if (scene->getCanvasSize() == specs.dim && + scene->getFps() == specs.fps && + scene->getFrameRange().fMax == specs.range.fMax) { return; } + const auto reply = QMessageBox::question(this, - tr("Adjust scene?"), - tr("Adjust scene to new video clip?")); + tr("Adjust scene to clip?"), + tr("Video clip and scene do not match, adjust scene to clip?\n\n" + "Clip: %1x%2 Fps: %3 Frames: %4\n\n" + "Scene: %5x%6 Fps: %7 Frames: %8") + .arg(QString::number(specs.dim.width()), + QString::number(specs.dim.height()), + QString::number(specs.fps), + QString::number(specs.range.fMax), + QString::number(scene->getCanvasWidth()), + QString::number(scene->getCanvasHeight()), + QString::number(scene->getFps()), + QString::number(scene->getFrameRange().fMax))); if (reply != QMessageBox::Yes) { return; } - scene->setCanvasSize(specs.width, specs.height); + scene->setCanvasSize(specs.dim.width(), + specs.dim.height()); scene->setFps(specs.fps); - scene->setFrameRange({0, specs.frames - 1}); + scene->setFrameRange(specs.range); } diff --git a/src/core/Boxes/videobox.cpp b/src/core/Boxes/videobox.cpp index ec8cedf04..1d66343cd 100644 --- a/src/core/Boxes/videobox.cpp +++ b/src/core/Boxes/videobox.cpp @@ -156,10 +156,10 @@ const VideoBox::VideoSpecs VideoBox::getSpecs() VideoSpecs specs; const auto h = mFileHandler->getFrameHandler(); if (!h) { return specs; } - specs.frames = h->getFrameCount(); + int frames = h->getFrameCount(); + specs.range = FrameRange{0, frames <= 1 ? 0 : frames - 1}; specs.fps = h->getFps(); - specs.height = h->getDim().height(); - specs.width = h->getDim().width(); + specs.dim = h->getDim(); return specs; } diff --git a/src/core/Boxes/videobox.h b/src/core/Boxes/videobox.h index 097a9a084..84a181225 100644 --- a/src/core/Boxes/videobox.h +++ b/src/core/Boxes/videobox.h @@ -41,10 +41,9 @@ class CORE_EXPORT VideoBox : public AnimationBox { QDomElement prp_writePropertyXEV_impl(const XevExporter& exp) const; public: struct VideoSpecs { - int width; - int height; - int frames; + QSize dim; qreal fps; + FrameRange range; }; void changeSourceFile();