From 5b2d889a4c75da9ac080a2396bb1c0c05a8faf72 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Tue, 13 Apr 2021 16:45:30 +0100 Subject: [PATCH 01/11] Add footage to root folder and set labels correctly. --- app/task/project/loadotio/loadotio.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index 1d672ace4..d1be16df0 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -215,6 +215,9 @@ bool LoadOTIOTask::Run() probed_item = new Footage(footage_url); imported_footage.insert(footage_url, probed_item); probed_item->setParent(project_); + + QFileInfo info(probed_item->filename()); + probed_item->SetLabel(info.fileName()); } Track::Reference reference; @@ -228,6 +231,9 @@ bool LoadOTIOTask::Run() QString output_id = reference.ToString(); Node::ConnectEdge(NodeOutput(probed_item, output_id), NodeInput(block, ClipBlock::kBufferIn)); + + FolderAddChild c(project_->root(), probed_item, false); + c.redo(); } } From 79b9d0b26befb9580a9daabc5818c954d5f87b9f Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Tue, 13 Apr 2021 17:03:52 +0100 Subject: [PATCH 02/11] Fix shadow variable. --- app/task/project/loadotio/loadotio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index d1be16df0..85f04f8d4 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -232,8 +232,8 @@ bool LoadOTIOTask::Run() Node::ConnectEdge(NodeOutput(probed_item, output_id), NodeInput(block, ClipBlock::kBufferIn)); - FolderAddChild c(project_->root(), probed_item, false); - c.redo(); + FolderAddChild add(project_->root(), probed_item, false); + add.redo(); } } From 0154cfc1c2d1616dcc63173d98d356a1a9092fd8 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Tue, 4 May 2021 15:36:48 +0100 Subject: [PATCH 03/11] Place footage into its own folder --- app/task/project/loadotio/loadotio.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index 85f04f8d4..aabc6447c 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -89,6 +89,12 @@ bool LoadOTIOTask::Run() sequence->setParent(project_); FolderAddChild(project_->root(), sequence).redo_now(); + // Create a folder for this sequence's footage + Folder* sequence_footage = new Folder(); + sequence_footage->SetLabel(QString::fromStdString(timeline->name())); + sequence_footage->setParent(project_); + FolderAddChild(project_->root(), sequence_footage).redo(); + // FIXME: As far as I know, OTIO doesn't store video/audio parameters? sequence->set_default_parameters(); @@ -232,7 +238,7 @@ bool LoadOTIOTask::Run() Node::ConnectEdge(NodeOutput(probed_item, output_id), NodeInput(block, ClipBlock::kBufferIn)); - FolderAddChild add(project_->root(), probed_item, false); + FolderAddChild add(sequence_footage, probed_item, false); add.redo(); } } From 2e681558511dbfdec4d2b69482b6c5d86fc01085 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Tue, 4 May 2021 16:00:18 +0100 Subject: [PATCH 04/11] Make sure footage is validated --- app/core.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/core.cpp b/app/core.cpp index dc41884a8..d76896b7d 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -1501,6 +1501,14 @@ void Core::CacheActiveSequence(bool in_out_only) bool Core::ValidateFootageInLoadedProject(Project* project, const QString& project_saved_url) { QVector project_footage = project->root()->ListChildrenOfType(); + + // OTIO files import their footage into a folder so check them too + foreach(Folder * folder, project->root()->ListChildrenOfType()) { + QVector footage = folder->ListChildrenOfType(); + if (!footage.isEmpty()) { + project_footage.append(footage); + } + } QVector footage_we_couldnt_validate; foreach (Footage* footage, project_footage) { From 332351d1d9f927d737d07669b7e101573013a4e1 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Tue, 4 May 2021 17:25:03 +0100 Subject: [PATCH 05/11] Move FolderAddChild to correct place to avoid duplicates --- app/task/project/loadotio/loadotio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index aabc6447c..488b57388 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -224,6 +224,9 @@ bool LoadOTIOTask::Run() QFileInfo info(probed_item->filename()); probed_item->SetLabel(info.fileName()); + + FolderAddChild add(sequence_footage, probed_item, false); + add.redo(); } Track::Reference reference; @@ -237,9 +240,6 @@ bool LoadOTIOTask::Run() QString output_id = reference.ToString(); Node::ConnectEdge(NodeOutput(probed_item, output_id), NodeInput(block, ClipBlock::kBufferIn)); - - FolderAddChild add(sequence_footage, probed_item, false); - add.redo(); } } From 2c2858e0abd828f06329c1e33fc968313e49957f Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Wed, 5 May 2021 16:31:06 +0100 Subject: [PATCH 06/11] Add second attempt at auto relink if first fails. --- app/dialog/footagerelink/footagerelinkdialog.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/dialog/footagerelink/footagerelinkdialog.cpp b/app/dialog/footagerelink/footagerelinkdialog.cpp index be04e097b..2f89de75e 100644 --- a/app/dialog/footagerelink/footagerelinkdialog.cpp +++ b/app/dialog/footagerelink/footagerelinkdialog.cpp @@ -133,6 +133,12 @@ void FootageRelinkDialog::BrowseForFootage() QString relative_to_original = original_dir.relativeFilePath(other_footage->filename()); QString absolute_to_new = new_dir.filePath(relative_to_original); + // Second attempt. Try appending the filename to our new filepath + if (!QFileInfo::exists(absolute_to_new)) { + QFileInfo file_info(other_footage->filename()); + absolute_to_new = new_dir.filePath(file_info.fileName()); + } + // Check if file exists if (QFileInfo::exists(absolute_to_new)) { other_footage->set_filename(absolute_to_new); From c86b7f6185e20346b8882dfc45dd74b9c7ed9cd3 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Wed, 5 May 2021 16:32:05 +0100 Subject: [PATCH 07/11] Make sure Olive doesn't overwrite OTIO files. --- app/task/project/loadotio/loadotio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index 488b57388..c3dc4f11e 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -58,7 +58,7 @@ bool LoadOTIOTask::Run() } project_ = new Project(); - project_->set_filename(GetFilename()); + project_->set_modified(true); std::vector timelines; From 2bdd5a370783e8ae7ab14a8415a6346026f35171 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Wed, 28 Jul 2021 15:52:24 +0100 Subject: [PATCH 08/11] Update to master --- app/task/project/loadotio/loadotio.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index c3dc4f11e..b0fe314b8 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -93,7 +93,7 @@ bool LoadOTIOTask::Run() Folder* sequence_footage = new Folder(); sequence_footage->SetLabel(QString::fromStdString(timeline->name())); sequence_footage->setParent(project_); - FolderAddChild(project_->root(), sequence_footage).redo(); + FolderAddChild(project_->root(), sequence_footage).redo_now(); // FIXME: As far as I know, OTIO doesn't store video/audio parameters? sequence->set_default_parameters(); @@ -226,7 +226,7 @@ bool LoadOTIOTask::Run() probed_item->SetLabel(info.fileName()); FolderAddChild add(sequence_footage, probed_item, false); - add.redo(); + add.redo_now(); } Track::Reference reference; From 1d2341245b0db3a2a112269cbc0d4a6c671ca0d3 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Sat, 7 Aug 2021 14:30:15 +0100 Subject: [PATCH 09/11] Correctly add footage nodes and setup contexts. --- app/task/project/loadotio/loadotio.cpp | 46 ++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index b0fe314b8..f8f26f93b 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -31,12 +31,19 @@ #include #include +#include "core.h" +#include "node/audio/volume/volume.h" #include "node/block/clip/clip.h" #include "node/block/gap/gap.h" #include "node/block/transition/crossdissolve/crossdissolvetransition.h" +#include "node/distort/transform/transformdistortnode.h" +#include "node/generator/matrix/matrix.h" +#include "node/math/math/math.h" #include "node/project/folder/folder.h" #include "node/project/footage/footage.h" #include "node/project/sequence/sequence.h" +#include "window/mainwindow/mainwindowundo.h" +#include "widget/nodeview/nodeviewundo.h" #include "widget/timelinewidget/undo/timelineundogeneral.h" namespace olive { @@ -222,27 +229,54 @@ bool LoadOTIOTask::Run() imported_footage.insert(footage_url, probed_item); probed_item->setParent(project_); + QFileInfo info(probed_item->filename()); probed_item->SetLabel(info.fileName()); - FolderAddChild add(sequence_footage, probed_item, false); + FolderAddChild add(sequence_footage, probed_item, true); add.redo_now(); } - Track::Reference reference; + // Add nodes to the graph and set up contexts + MultiUndoCommand* command = new MultiUndoCommand(); + command->add_child(new NodeAddCommand(sequence->parent(), block)); + + // Position clip in its own context + command->add_child(new NodeSetPositionCommand(block, block, QPointF(0, 0), false)); + + // Position footage in its context + command->add_child(new NodeSetPositionCommand(probed_item, block, QPointF(-2, 0), false)); + + + Track::Reference reference; if (track->type() == Track::kVideo) { reference = Track::Reference(Track::kVideo, 0); + QString output_id = reference.ToString(); + + TransformDistortNode* transform = new TransformDistortNode(); + command->add_child(new NodeAddCommand(sequence->parent(), transform)); + + command->add_child(new NodeEdgeAddCommand(NodeOutput(probed_item, output_id), + NodeInput(transform, TransformDistortNode::kTextureInput))); + command->add_child(new NodeEdgeAddCommand(transform, NodeInput(block, ClipBlock::kBufferIn))); + command->add_child(new NodeSetPositionCommand(transform, block, QPointF(-1, 0), false)); } else { reference = Track::Reference(Track::kAudio, 0); + QString output_id = reference.ToString(); + + VolumeNode* volume_node = new VolumeNode(); + command->add_child(new NodeAddCommand(sequence->parent(), volume_node)); + + command->add_child(new NodeEdgeAddCommand(NodeOutput(probed_item, output_id), + NodeInput(volume_node, VolumeNode::kSamplesInput))); + command->add_child(new NodeEdgeAddCommand(volume_node, NodeInput(block, ClipBlock::kBufferIn))); + command->add_child(new NodeSetPositionCommand(volume_node, block, QPointF(-1, 0), false)); } - QString output_id = reference.ToString(); - - Node::ConnectEdge(NodeOutput(probed_item, output_id), NodeInput(block, ClipBlock::kBufferIn)); + Core::instance()->undo_stack()->pushIfHasChildren(command); } } - } } } From 850b75fe246308517d7346670709d64f09bd8e9b Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Sat, 7 Aug 2021 15:06:50 +0100 Subject: [PATCH 10/11] Transitiosn and gaps are now added. Also removed unnecessary code --- app/core.cpp | 8 -------- app/task/project/loadotio/loadotio.cpp | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/core.cpp b/app/core.cpp index d76896b7d..dc41884a8 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -1501,14 +1501,6 @@ void Core::CacheActiveSequence(bool in_out_only) bool Core::ValidateFootageInLoadedProject(Project* project, const QString& project_saved_url) { QVector project_footage = project->root()->ListChildrenOfType(); - - // OTIO files import their footage into a folder so check them too - foreach(Folder * folder, project->root()->ListChildrenOfType()) { - QVector footage = folder->ListChildrenOfType(); - if (!footage.isEmpty()) { - project_footage.append(footage); - } - } QVector footage_we_couldnt_validate; foreach (Footage* footage, project_footage) { diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index f8f26f93b..d327b7a71 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -206,6 +206,28 @@ bool LoadOTIOTask::Run() transition_block->set_media_in(rational::fromDouble(-otio_block_transition->out_offset().to_seconds())); } prev_block_transition = true; + + // Add nodes to the graph and set up contexts + MultiUndoCommand* command = new MultiUndoCommand(); + + command->add_child(new NodeAddCommand(sequence->parent(), block)); + + // Position transition in its own context + command->add_child(new NodeSetPositionCommand(block, block, QPointF(0, 0), false)); + + Core::instance()->undo_stack()->pushIfHasChildren(command); + } + + if (otio_block->schema_name() == "Gap") { + // Add nodes to the graph and set up contexts + MultiUndoCommand* command = new MultiUndoCommand(); + + command->add_child(new NodeAddCommand(sequence->parent(), block)); + + // Position transition in its own context + command->add_child(new NodeSetPositionCommand(block, block, QPointF(0, 0), false)); + + Core::instance()->undo_stack()->pushIfHasChildren(command); } // Update this after it's used but before any continue statements From 64a3cb5c84a4254cfc7af30933b7c7c4132de3af Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Tue, 17 Aug 2021 13:13:02 +0100 Subject: [PATCH 11/11] Replace undo commands with non undoable functions. --- app/task/project/loadotio/loadotio.cpp | 45 +++++++++----------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/app/task/project/loadotio/loadotio.cpp b/app/task/project/loadotio/loadotio.cpp index d327b7a71..149ca6906 100644 --- a/app/task/project/loadotio/loadotio.cpp +++ b/app/task/project/loadotio/loadotio.cpp @@ -208,26 +208,18 @@ bool LoadOTIOTask::Run() prev_block_transition = true; // Add nodes to the graph and set up contexts - MultiUndoCommand* command = new MultiUndoCommand(); - - command->add_child(new NodeAddCommand(sequence->parent(), block)); + block->setParent(sequence->parent()); // Position transition in its own context - command->add_child(new NodeSetPositionCommand(block, block, QPointF(0, 0), false)); - - Core::instance()->undo_stack()->pushIfHasChildren(command); + sequence->parent()->SetNodePosition(block, block, QPointF(0, 0)); } if (otio_block->schema_name() == "Gap") { // Add nodes to the graph and set up contexts - MultiUndoCommand* command = new MultiUndoCommand(); - - command->add_child(new NodeAddCommand(sequence->parent(), block)); + block->setParent(sequence->parent()); // Position transition in its own context - command->add_child(new NodeSetPositionCommand(block, block, QPointF(0, 0), false)); - - Core::instance()->undo_stack()->pushIfHasChildren(command); + sequence->parent()->SetNodePosition(block, block, QPointF(0, 0)); } // Update this after it's used but before any continue statements @@ -260,15 +252,13 @@ bool LoadOTIOTask::Run() } // Add nodes to the graph and set up contexts - MultiUndoCommand* command = new MultiUndoCommand(); - - command->add_child(new NodeAddCommand(sequence->parent(), block)); + block->setParent(sequence->parent()); // Position clip in its own context - command->add_child(new NodeSetPositionCommand(block, block, QPointF(0, 0), false)); + sequence->parent()->SetNodePosition(block, block, QPointF(0, 0)); // Position footage in its context - command->add_child(new NodeSetPositionCommand(probed_item, block, QPointF(-2, 0), false)); + sequence->parent()->SetNodePosition(probed_item, block, QPointF(-2, 0)); Track::Reference reference; @@ -277,26 +267,23 @@ bool LoadOTIOTask::Run() QString output_id = reference.ToString(); TransformDistortNode* transform = new TransformDistortNode(); - command->add_child(new NodeAddCommand(sequence->parent(), transform)); + transform->setParent(sequence->parent()); - command->add_child(new NodeEdgeAddCommand(NodeOutput(probed_item, output_id), - NodeInput(transform, TransformDistortNode::kTextureInput))); - command->add_child(new NodeEdgeAddCommand(transform, NodeInput(block, ClipBlock::kBufferIn))); - command->add_child(new NodeSetPositionCommand(transform, block, QPointF(-1, 0), false)); + Node::ConnectEdge(NodeOutput(probed_item, output_id), + NodeInput(transform, TransformDistortNode::kTextureInput)); + Node::ConnectEdge(transform, NodeInput(block, ClipBlock::kBufferIn)); + sequence->parent()->SetNodePosition(transform, block, QPointF(-1, 0)); } else { reference = Track::Reference(Track::kAudio, 0); QString output_id = reference.ToString(); VolumeNode* volume_node = new VolumeNode(); - command->add_child(new NodeAddCommand(sequence->parent(), volume_node)); + volume_node->setParent(sequence->parent()); - command->add_child(new NodeEdgeAddCommand(NodeOutput(probed_item, output_id), - NodeInput(volume_node, VolumeNode::kSamplesInput))); - command->add_child(new NodeEdgeAddCommand(volume_node, NodeInput(block, ClipBlock::kBufferIn))); - command->add_child(new NodeSetPositionCommand(volume_node, block, QPointF(-1, 0), false)); + Node::ConnectEdge(NodeOutput(probed_item, output_id), NodeInput(volume_node, VolumeNode::kSamplesInput)); + Node::ConnectEdge(volume_node, NodeInput(block, ClipBlock::kBufferIn)); + sequence->parent()->SetNodePosition(volume_node, block, QPointF(-1, 0)); } - - Core::instance()->undo_stack()->pushIfHasChildren(command); } } }