Merge pull request #1330 from ThomasWilshaw/OTIO_load

OTIO load
This commit is contained in:
itsmattkc
2022-01-07 19:35:38 -08:00
committed by GitHub
7 changed files with 208 additions and 5 deletions
+11
View File
@@ -43,6 +43,9 @@
#include "dialog/autorecovery/autorecoverydialog.h"
#include "dialog/export/export.h"
#include "dialog/footagerelink/footagerelinkdialog.h"
#ifdef USE_OTIO
#include "dialog/otioproperties/otiopropertiesdialog.h"
#endif
#include "dialog/sequence/sequence.h"
#include "dialog/task/task.h"
#include "dialog/preferences/preferences.h"
@@ -375,6 +378,14 @@ void Core::DialogExportShow()
}
}
#ifdef USE_OTIO
bool Core::DialogImportOTIOShow(const QList<Sequence*>& sequences) {
Project* active_project = GetActiveProject();
OTIOPropertiesDialog opd(sequences, active_project);
return opd.exec() == QDialog::Accepted;
}
#endif
void Core::CreateNewFolder()
{
// Locate the most recently focused Project panel (assume that's the panel the user wants to import into)
+7
View File
@@ -396,6 +396,13 @@ public slots:
*/
void DialogExportShow();
/**
* @brief Show OTIO import dialog
*/
#ifdef USE_OTIO
bool DialogImportOTIOShow(const QList<Sequence*>& sequences);
#endif
/**
* @brief Create a new folder in the currently active project
*/
+3
View File
@@ -24,6 +24,9 @@ add_subdirectory(export)
add_subdirectory(footageproperties)
add_subdirectory(footagerelink)
add_subdirectory(keyframeproperties)
if(OpenTimelineIO_FOUND)
add_subdirectory(otioproperties)
endif()
add_subdirectory(preferences)
add_subdirectory(progress)
add_subdirectory(rendercancel)
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2019 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
dialog/otioproperties/otiopropertiesdialog.h
dialog/otioproperties/otiopropertiesdialog.cpp
PARENT_SCOPE
)
@@ -0,0 +1,81 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "otiopropertiesdialog.h"
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QFileInfo>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include "core.h"
#include "dialog/sequence/sequence.h"
namespace olive {
OTIOPropertiesDialog::OTIOPropertiesDialog(const QList<Sequence*>& sequences, Project* active_project, QWidget* parent)
:
QDialog(parent),
sequences_(sequences)
{
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(tr("OpenTimelineIO files to not store sequence properties (resolution, framerate etc.).\n"
"Set the correct parameters here or they will be left at the default setting.")));
table_ = new QTreeWidget();
table_->setColumnCount(2);
table_->setHeaderLabels({tr("Sequence"), tr("Actions")});
table_->setRootIsDecorated(false);
for (int i = 0; i < sequences.size(); i++) {
QTreeWidgetItem* item = new QTreeWidgetItem();
Sequence* s = sequences.at(i);
QWidget* item_actions = new QWidget();
QHBoxLayout* item_actions_layout = new QHBoxLayout(item_actions);
QPushButton* item_settings_btn = new QPushButton(tr("Settings"));
item_settings_btn->setProperty("index", i);
connect(item_settings_btn, &QPushButton::clicked, this, &OTIOPropertiesDialog::SetupSequence);
item_actions_layout->addWidget(item_settings_btn);
item->setText(0, s->GetLabel());
table_->addTopLevelItem(item);
table_->setItemWidget(item, 1, item_actions);
}
layout->addWidget(table_);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
connect(buttons, &QDialogButtonBox::accepted, this, &OTIOPropertiesDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, this, &OTIOPropertiesDialog::reject);
layout->addWidget(buttons);
setWindowTitle(tr("Load OpenTimelineIO File"));
}
void OTIOPropertiesDialog::SetupSequence() {
int index = sender()->property("index").toInt();
Sequence* s = sequences_.at(index);
SequenceDialog sd(s, SequenceDialog::kNew);
sd.SetUndoable(false);
sd.exec();
}
} // namespace olive
@@ -0,0 +1,39 @@
#ifndef OTIOPROPERTIESDIALOG_H
#define OTIOPROPERTIESDIALOG_H
#include <QDialog>
#include <QTreeWidget>
#include "common/define.h"
#include "opentimelineio/timeline.h"
#include "node/project/sequence/sequence.h"
#include "node/project/project.h"
namespace olive {
/**
* @brief Dialog to load setting for OTIO sequences.
*
* Takes a list of Sequences and allows the setting of options for each.
*/
class OTIOPropertiesDialog : public QDialog {
Q_OBJECT
public:
OTIOPropertiesDialog(const QList<Sequence*>& sequences, Project* active_project, QWidget* parent = nullptr);
private:
QTreeWidget* table_;
const QList<Sequence*> sequences_;
private slots:
/**
* @brief Brings up the Sequence settings dialog.
*/
void SetupSequence();
};
} //namespace olive
#endif // OTIOPROPERTIESDIALOG_H
+45 -5
View File
@@ -30,6 +30,7 @@
#include <opentimelineio/transition.h>
#include <QApplication>
#include <QFileInfo>
#include <QThread>
#include "core.h"
#include "node/audio/volume/volume.h"
@@ -88,11 +89,51 @@ bool LoadOTIOTask::Run()
// Keep track of imported footage
QMap<QString, Footage*> imported_footage;
QMap<OTIO::Timeline*, Sequence*> timeline_sequnce_map;
// Variables used for loading bar
float number_of_clips = 0;
float clips_done = 0;
// Generate a list of sequences with the same names as the timelines.
// Assumes each timeline has a unique name.
int unnamed_sequence_count = 0;
foreach (auto timeline, timelines) {
// Create sequence
Sequence* sequence = new Sequence();
sequence->SetLabel(QString::fromStdString(timeline->name()));
if (!timeline->name().empty()) {
sequence->SetLabel(QString::fromStdString(timeline->name()));
} else {
// If the otio timeline does not provide a name, create a default one here
unnamed_sequence_count++;
QString label = tr("Sequence %1").arg(unnamed_sequence_count);
sequence->SetLabel(QString::fromStdString(label.toStdString()));
}
// Set default params incase they aren't edited.
sequence->set_default_parameters();
timeline_sequnce_map.insert(timeline, sequence);
// Get number of clips for loading bar
foreach (auto track, timeline->tracks()->children()) {
auto otio_track = static_cast<OTIO::Track*>(track.value);
number_of_clips += otio_track->children().size();
}
}
// Dialog has to be called from the main thread so we pass the list of sequences here.
bool accepted = false;
QMetaObject::invokeMethod(Core::instance(),
"DialogImportOTIOShow",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, accepted),
Q_ARG(QList<Sequence*>,timeline_sequnce_map.values()));
if (!accepted) {
SetError(tr("Loading OpenTimelineIO file(s) was canceled"));
return false;
}
foreach (auto timeline, timeline_sequnce_map.keys()) {
Sequence* sequence = timeline_sequnce_map.value(timeline);
sequence->setParent(project_);
FolderAddChild(project_->root(), sequence).redo_now();
@@ -102,9 +143,6 @@ bool LoadOTIOTask::Run()
sequence_footage->setParent(project_);
FolderAddChild(project_->root(), sequence_footage).redo_now();
// FIXME: As far as I know, OTIO doesn't store video/audio parameters?
sequence->set_default_parameters();
// Iterate through tracks
for (auto c : timeline->tracks()->children()) {
auto otio_track = static_cast<OTIO::Track*>(c.value);
@@ -277,6 +315,8 @@ bool LoadOTIOTask::Run()
}
}
}
clips_done++;
emit ProgressChanged(clips_done / number_of_clips);
}
}
}