build: split the engine into liboakengine.so; worker drops the UI entirely

Physical split: app/{audio,cli,codec,common,config,node,pluginSupport,
render,task,timeline,undo,tool,shaders} plus coreengine, version and
ui/icons+colorcoding move to a new top-level engine/ tree, built as
liboakengine.so (shared). The render backends (oakgl/oakvulkan) move
with it and link the engine library instead of embedding a static
render-core subset (libolive-rendercore is gone).

- oak-render-worker now links liboakengine instead of the whole
  libolive-editor object set: 336MB -> 2.9MB, no Qt Widgets UI
- the editor links liboakengine for the engine and keeps only UI
  objects in libolive-editor
- install/packaging: GNUInstallDirs libdir on Linux, bundle copy on
  macOS, oakengine.dll staged for NSIS, AppImage validation entry
- fix backend lookup for the new layout: DynamicRenderer searched
  ../app but backends now live in engine/; a stale pre-split liboakgl
  in the build tree got dlopened instead, re-initialized and later
  destroyed the interposed engine statics (full-suite segfault at
  DialogSequenceParameterTab, found via gdb watchpoint)
This commit is contained in:
2026-07-20 03:23:28 +08:00
parent 026ff94b5e
commit 28c4426236
604 changed files with 243 additions and 172 deletions
+29
View File
@@ -0,0 +1,29 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 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/>.
if (OpenTimelineIO_FOUND)
add_subdirectory(loadotio)
add_subdirectory(saveotio)
endif ()
add_subdirectory(import)
add_subdirectory(load)
add_subdirectory(save)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
PARENT_SCOPE
)
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 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}
task/project/import/import.h
task/project/import/import.cpp
PARENT_SCOPE
)
+302
View File
@@ -0,0 +1,302 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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 "import.h"
#include <QDir>
#include <QFileInfo>
#include "config/config.h"
#include "coreengine.h"
#include "node/nodeundo.h"
#include "node/project/footage/footage.h"
namespace olive
{
ProjectImportTask::ProjectImportTask(Folder *folder,
const QStringList &filenames)
: command_(nullptr)
, folder_(folder)
{
foreach (const QString &f, filenames) {
filenames_.append(QFileInfo(f));
}
file_count_ = EngineCore::count_files_in_file_list(filenames_);
set_title(tr("Importing %n file(s)", nullptr, file_count_));
}
const int &ProjectImportTask::get_file_count() const
{
return file_count_;
}
bool ProjectImportTask::run()
{
command_ = new MultiUndoCommand();
int imported = 0;
import(folder_, filenames_, imported, command_);
if (is_cancelled()) {
delete command_;
command_ = nullptr;
return false;
} else {
return true;
}
}
void ProjectImportTask::import(Folder *folder, QFileInfoList entries,
int &counter, MultiUndoCommand *parent_command)
{
for (int i = 0; i < entries.size(); i++) {
if (is_cancelled()) {
break;
}
const QFileInfo &file_info = entries.at(i);
// Check if this file is a directory
if (file_info.isDir()) {
// QDir::entryList only returns filenames, we can use entryInfoList() to get full paths
QFileInfoList entry_list =
QDir(file_info.absoluteFilePath()).entryInfoList();
// Strip out "." and ".." (for some reason QDir::NoDotAndDotDot doesn't work with entryInfoList, so we have to
// check manually)
for (int j = 0; j < entry_list.size(); j++) {
if (entry_list.at(j).fileName() == QStringLiteral(".") ||
entry_list.at(j).fileName() == QStringLiteral("..")) {
entry_list.removeAt(j);
j--;
}
}
// Only proceed if the empty actually has files in it
if (!entry_list.isEmpty()) {
// Create a folder corresponding to the directory
Folder *f = new Folder();
f->set_label(file_info.fileName());
// Create undoable command that adds the items to the model
add_item_to_folder(folder, f, parent_command);
// Recursively follow this path
import(f, entry_list, counter, parent_command);
}
} else {
Footage *footage = new Footage();
footage->set_cancel_pointer(this->get_cancel_atom());
footage->set_filename(file_info.absoluteFilePath());
footage->set_label(file_info.fileName());
footage->set_cancel_pointer(nullptr);
if (footage->is_valid()) {
// See if this footage is an image sequence
validate_image_sequence(footage, entries, i);
// Create undoable command that adds the items to the model
add_item_to_folder(folder, footage, parent_command);
// Add to vector
imported_footage_.push_back(footage);
} else {
// Add to list so we can tell the user about it later
invalid_files_.append(file_info.absoluteFilePath());
delete footage;
}
counter++;
emit progress_changed(static_cast<double>(counter) /
static_cast<double>(file_count_));
}
}
}
void ProjectImportTask::validate_image_sequence(Footage *footage,
QFileInfoList &info_list,
int index)
{
// Heuristically determine whether this file is part of an image sequence or not
//
// By this point we've established that video contains a single still image stream. Now we'll
// see if it ends with numbers.
if (Decoder::get_image_sequence_digit_count(footage->filename()) > 0 &&
!image_sequence_ignore_files_.contains(footage->filename()) &&
footage->input_array_size(Footage::k_video_params_input)) {
VideoParams video_stream = footage->get_video_params(0);
QSize dim(video_stream.width(), video_stream.height());
int64_t ind = Decoder::get_image_sequence_index(footage->filename());
// Check if files around exist around it with that follow a sequence
QString previous_img_fn = Decoder::transform_image_sequence_file_name(
footage->filename(), ind - 1);
QString next_img_fn = Decoder::transform_image_sequence_file_name(
footage->filename(), ind + 1);
Footage *previous_file = new Footage(previous_img_fn);
Footage *next_file = new Footage(next_img_fn);
// Finally see if these files have the same dimensions
if ((previous_file->is_valid() &&
compare_still_image_size(previous_file, dim)) ||
(next_file->is_valid() && compare_still_image_size(next_file, dim))) {
// By this point, we've established this file is a still image with a number at the end of
// the filename surrounded by adjacent numbers. It could be a still image! But let's ask the
// user just in case...
bool is_sequence;
QMetaObject::invokeMethod(EngineCore::instance(), "confirm_image_sequence",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, is_sequence),
Q_ARG(QString, footage->filename()));
int64_t seq_index =
Decoder::get_image_sequence_index(footage->filename());
// Heuristic to find the first and last images (users can always override this later in
// FootagePropertiesDialog)
int64_t start_index =
get_image_sequence_limit(footage->filename(), seq_index, false);
int64_t end_index =
get_image_sequence_limit(footage->filename(), seq_index, true);
// Depending on the user's choice, either remove them from the list or don't ask for the
// remainders
for (int64_t j = start_index; j <= end_index; j++) {
QString entry_fn = Decoder::transform_image_sequence_file_name(
footage->filename(), j);
if (is_sequence) {
// If this is part of the sequence we're importing here, remove it
for (int i = index + 1; i < info_list.size(); i++) {
if (info_list.at(i).absoluteFilePath() == entry_fn) {
if (is_sequence) {
info_list.removeAt(i);
}
break;
}
}
} else {
image_sequence_ignore_files_.append(entry_fn);
}
}
if (is_sequence) {
// User has confirmed it is a still image, let's set it accordingly.
video_stream.set_video_type(
VideoParams::k_video_type_image_sequence);
Rational default_timebase =
OAK_CONFIG("DefaultSequenceFrameRate").value<Rational>();
video_stream.set_time_base(default_timebase);
video_stream.set_frame_rate(default_timebase.flipped());
video_stream.set_start_time(start_index);
video_stream.set_duration(end_index - start_index + 1);
footage->set_video_params(video_stream, 0);
}
}
delete previous_file;
delete next_file;
}
}
void ProjectImportTask::add_item_to_folder(Folder *folder, Node *item,
MultiUndoCommand *command)
{
// Create undoable command that adds the items to the model
Project *project = folder_->project();
NodeAddCommand *nac = new NodeAddCommand(project, item);
nac->push_to_thread(project->thread());
command->add_child(nac);
command->add_child(new FolderAddChild(folder, item));
}
bool ProjectImportTask::item_is_still_image_footage_only(Footage *footage)
{
if (footage->get_total_stream_count() != 1) {
// Footage with more than one stream (usually video+audio) most likely isn't an image sequence
return false;
}
VideoParams vp = footage->get_video_params(0);
// Footage must be valid and video stream must be a still image to be an image sequence
return vp.is_valid() && vp.video_type() == VideoParams::k_video_type_still;
}
bool ProjectImportTask::compare_still_image_size(Footage *footage, const QSize &sz)
{
if (!item_is_still_image_footage_only(footage)) {
return false;
}
VideoParams stream = footage->get_video_params(0);
return stream.width() == sz.width() && stream.height() == sz.height();
}
int64_t ProjectImportTask::get_image_sequence_limit(const QString &start_fn,
int64_t start, bool up)
{
QString test_filename;
int test_index;
forever
{
if (up) {
test_index = start + 1;
} else {
test_index = start - 1;
}
test_filename =
Decoder::transform_image_sequence_file_name(start_fn, test_index);
if (!QFileInfo::exists(test_filename)) {
// Reached end of index
break;
}
start = test_index;
}
return start;
}
}
+99
View File
@@ -0,0 +1,99 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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/>.
***/
#ifndef OAK_PROJECTIMPORTMANAGER_H
#define OAK_PROJECTIMPORTMANAGER_H
#include <QFileInfoList>
#include <QUndoCommand>
#include "codec/decoder.h"
#include "node/project/footage/footage.h"
#include "node/project/folder/folder.h"
#include "task/task.h"
namespace olive
{
class ProjectImportTask : public Task {
Q_OBJECT
public:
ProjectImportTask(Folder *folder, const QStringList &filenames);
const int &get_file_count() const;
MultiUndoCommand *get_command() const
{
return command_;
}
const QStringList &get_invalid_files() const
{
return invalid_files_;
}
bool has_invalid_files() const
{
return !invalid_files_.isEmpty();
}
const QVector<Footage *> &get_imported_footage() const
{
return imported_footage_;
}
protected:
virtual bool run() override;
private:
void import(Folder *folder, QFileInfoList entries, int &counter,
MultiUndoCommand *parent_command);
void validate_image_sequence(Footage *footage, QFileInfoList &info_list,
int index);
void add_item_to_folder(Folder *folder, Node *item, MultiUndoCommand *command);
static bool item_is_still_image_footage_only(Footage *footage);
static bool compare_still_image_size(Footage *footage, const QSize &sz);
static int64_t get_image_sequence_limit(const QString &start_fn, int64_t start,
bool up);
MultiUndoCommand *command_;
Folder *folder_;
QFileInfoList filenames_;
int file_count_;
QStringList invalid_files_;
QList<QString> image_sequence_ignore_files_;
QVector<Footage *> imported_footage_;
};
}
#endif // OAK_PROJECTIMPORTMANAGER_H
+24
View File
@@ -0,0 +1,24 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 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}
task/project/load/load.h
task/project/load/load.cpp
task/project/load/loadbasetask.h
task/project/load/loadbasetask.cpp
PARENT_SCOPE
)
+90
View File
@@ -0,0 +1,90 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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 "load.h"
#include <QApplication>
#include "node/project/serializer/serializer.h"
namespace olive
{
ProjectLoadTask::ProjectLoadTask(const QString &filename)
: ProjectLoadBaseTask(filename)
{
}
bool ProjectLoadTask::run()
{
project_ = new Project();
project_->set_filename(get_filename());
ProjectSerializer::Result result = ProjectSerializer::load(
project_, get_filename(), ProjectSerializer::k_project);
layout_ = result.get_load_data().layout;
switch (result.code()) {
case ProjectSerializer::k_success:
break;
case ProjectSerializer::k_project_too_old:
set_error(tr(
"This project is from a version of Oak Video Editor that is no longer supported in this version."));
break;
case ProjectSerializer::k_project_too_new:
set_error(tr(
"This project is from a newer version of Oak Video Editor and cannot be opened in this version."));
break;
case ProjectSerializer::k_unknown_version:
set_error(tr("Failed to determine project version."));
break;
case ProjectSerializer::k_file_error:
set_error(
tr("Failed to read file \"%1\" for reading.").arg(get_filename()));
break;
case ProjectSerializer::k_xml_error:
set_error(
tr("Failed to read XML document. File may be corrupt. Error was: %1")
.arg(result.get_details()));
break;
case ProjectSerializer::k_no_data:
set_error(tr("Failed to find any data to parse."));
break;
// Errors that should never be thrown by a load
case ProjectSerializer::k_overwrite_error:
set_error(tr("Unknown error."));
break;
}
if (result == ProjectSerializer::k_success) {
project_->moveToThread(qApp->thread());
return true;
} else {
delete project_;
project_ = nullptr;
return false;
}
}
}
+42
View File
@@ -0,0 +1,42 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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/>.
***/
#ifndef OAK_PROJECTLOADMANAGER_H
#define OAK_PROJECTLOADMANAGER_H
#include "loadbasetask.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
namespace olive
{
class ProjectLoadTask : public ProjectLoadBaseTask {
Q_OBJECT
public:
ProjectLoadTask(const QString &filename);
protected:
virtual bool run() override;
};
}
#endif // OAK_PROJECTLOADMANAGER_H
+34
View File
@@ -0,0 +1,34 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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 "loadbasetask.h"
namespace olive
{
ProjectLoadBaseTask::ProjectLoadBaseTask(const QString &filename)
: project_(nullptr)
, filename_(filename)
{
set_title(tr("Loading '%1'").arg(filename));
}
}
+63
View File
@@ -0,0 +1,63 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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/>.
***/
#ifndef OAK_PROJECTLOADBASETASK_H
#define OAK_PROJECTLOADBASETASK_H
#include "node/project.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
#include "task/task.h"
namespace olive
{
class ProjectLoadBaseTask : public Task {
Q_OBJECT
public:
ProjectLoadBaseTask(const QString &filename);
Project *get_loaded_project() const
{
return project_;
}
const QString &get_filename() const
{
return filename_;
}
const MainWindowLayoutInfo &get_loaded_layout() const
{
return layout_;
}
protected:
Project *project_;
MainWindowLayoutInfo layout_;
private:
QString filename_;
};
}
#endif // LOADBASETASK_H
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 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}
task/project/loadotio/loadotio.h
task/project/loadotio/loadotio.cpp
PARENT_SCOPE
)
+378
View File
@@ -0,0 +1,378 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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 "loadotio.h"
#ifdef USE_OTIO
#include <opentimelineio/clip.h>
#include <opentimelineio/externalReference.h>
#include <opentimelineio/gap.h>
#include <opentimelineio/serializableCollection.h>
#include <opentimelineio/timeline.h>
#include <opentimelineio/transition.h>
#include <QApplication>
#include <QFileInfo>
#include <QThread>
#include "coreengine.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/nodeundo.h"
#include "node/project/folder/folder.h"
#include "node/project/footage/footage.h"
#include "node/project/sequence/sequence.h"
#include "timeline/timelineundogeneral.h"
#include "window/mainwindow/mainwindowundo.h"
namespace olive
{
LoadOTIOTask::LoadOTIOTask(const QString &s)
: ProjectLoadBaseTask(s)
{
}
bool LoadOTIOTask::Run()
{
OTIO::ErrorStatus es;
auto root = OTIO::SerializableObjectWithMetadata::from_json_file(
GetFilename().toStdString(), &es);
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
SetError(
tr("Failed to load OpenTimelineIO from file \"%1\" \n\nOpenTimelineIO Error:\n\n%2")
.arg(GetFilename(),
QString::fromStdString(es.full_description)));
return false;
}
project_ = new Project();
project_->Initialize();
project_->set_modified(true);
std::vector<OTIO::Timeline *> timelines;
if (root->schema_name() == "SerializableCollection") {
// This is a number of timelines
std::vector<OTIO::SerializableObject::Retainer<OTIO::SerializableObject>>
&root_children =
static_cast<OTIO::SerializableCollection *>(root)->children();
timelines.resize(root_children.size());
for (size_t j = 0; j < root_children.size(); j++) {
timelines[j] =
static_cast<OTIO::Timeline *>(root_children[j].value);
}
} else if (root->schema_name() == "Timeline") {
// This is a single timeline
timelines.push_back(static_cast<OTIO::Timeline *>(root));
} else {
// Unknown root, we don't know what to do with this
SetError(tr("Unknown OpenTimelineIO root element"));
delete project_;
project_ = nullptr;
return false;
}
// 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) {
Sequence *sequence = new Sequence();
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(
EngineCore::instance(), "show_otio_import_dialog", Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, accepted),
Q_ARG(QList<Sequence *>, timeline_sequnce_map.values()));
if (!accepted) {
// Cancel to indicate to caller that this task did not complete and to simply dispose of it
Cancel();
qDeleteAll(timeline_sequnce_map); // Clear sequences
return true;
}
foreach (auto timeline, timeline_sequnce_map.keys()) {
Sequence *sequence = timeline_sequnce_map.value(timeline);
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_now();
// Iterate through tracks
for (auto c : timeline->tracks()->children()) {
auto otio_track = static_cast<OTIO::Track *>(c.value);
// Create a new track
Track *track = nullptr;
// Determine what kind of track it is
if (otio_track->kind() == "Video" ||
otio_track->kind() == "Audio") {
Track::Type type;
if (otio_track->kind() == "Video") {
type = Track::kVideo;
} else {
type = Track::kAudio;
}
// Create track
TimelineAddTrackCommand t(sequence->track_list(type));
t.redo_now();
track = t.track();
} else {
qWarning() << "Found unknown track type:"
<< otio_track->kind().c_str();
continue;
}
// Get clips from track
auto clip_map = otio_track->children();
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
SetError(tr("Failed to load clip"));
return false;
}
Block *previous_block = nullptr;
bool prev_block_transition = false;
for (auto otio_block_retainer : clip_map) {
auto otio_block = otio_block_retainer.value;
Block *block = nullptr;
if (otio_block->schema_name() == "Clip") {
block = new ClipBlock();
} else if (otio_block->schema_name() == "Gap") {
block = new GapBlock();
} else if (otio_block->schema_name() == "Transition") {
// Todo: Look into OTIO supported transitions and add them to Olive
block = new CrossDissolveTransition();
} else {
// We don't know what this is yet, just create a gap for now so that *something* is there
qWarning() << "Found unknown block type:"
<< otio_block->schema_name().c_str();
block = new GapBlock();
}
block->setParent(project_);
block->SetLabel(QString::fromStdString(otio_block->name()));
track->AppendBlock(block);
Rational start_time;
Rational duration;
if (otio_block->schema_name() == "Clip" ||
otio_block->schema_name() == "Gap") {
start_time = Rational::fromDouble(
static_cast<OTIO::Item *>(otio_block)
->source_range()
->start_time()
.to_seconds());
duration = Rational::fromDouble(
static_cast<OTIO::Item *>(otio_block)
->source_range()
->duration()
.to_seconds());
if (otio_block->schema_name() == "Clip") {
static_cast<ClipBlock *>(block)->set_media_in(
start_time);
}
block->set_length_and_media_out(duration);
}
// If the previous block was a transition, connect the current block to it
if (prev_block_transition) {
TransitionBlock *previous_transition_block =
static_cast<TransitionBlock *>(previous_block);
Node::ConnectEdge(
block, NodeInput(previous_transition_block,
TransitionBlock::kInBlockInput));
prev_block_transition = false;
}
if (otio_block->schema_name() == "Transition") {
TransitionBlock *transition_block =
static_cast<TransitionBlock *>(block);
OTIO::Transition *otio_block_transition =
static_cast<OTIO::Transition *>(otio_block);
// Set how far the transition eats into the previous clip
transition_block->set_offsets_and_length(
Rational::fromRationalTime(
otio_block_transition->in_offset()),
Rational::fromRationalTime(
otio_block_transition->out_offset()));
if (previous_block) {
Node::ConnectEdge(
previous_block,
NodeInput(transition_block,
TransitionBlock::kOutBlockInput));
}
prev_block_transition = true;
// Add nodes to the graph and set up contexts
block->setParent(sequence->parent());
// Position transition in its own context
block->SetNodePositionInContext(block, QPointF(0, 0));
}
if (otio_block->schema_name() == "Gap") {
// Add nodes to the graph and set up contexts
block->setParent(sequence->parent());
// Position transition in its own context
block->SetNodePositionInContext(block, QPointF(0, 0));
}
// Update this after it's used but before any continue statements
previous_block = block;
if (otio_block->schema_name() == "Clip") {
auto otio_clip = static_cast<OTIO::Clip *>(otio_block);
if (!otio_clip->media_reference()) {
continue;
}
if (otio_clip->media_reference()->schema_name() ==
"ExternalReference") {
// Link footage
QString footage_url = QString::fromStdString(
static_cast<OTIO::ExternalReference *>(
otio_clip->media_reference())
->target_url());
Footage *probed_item;
if (imported_footage.contains(footage_url)) {
probed_item = imported_footage.value(footage_url);
} else {
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());
FolderAddChild add(sequence_footage, probed_item);
add.redo_now();
}
// Add nodes to the graph and set up contexts
block->setParent(sequence->parent());
// Position clip in its own context
block->SetNodePositionInContext(block, QPointF(0, 0));
// Position footage in its context
block->SetNodePositionInContext(probed_item,
QPointF(-2, 0));
if (track->type() == Track::kVideo) {
TransformDistortNode *transform =
new TransformDistortNode();
transform->setParent(sequence->parent());
Node::ConnectEdge(
probed_item,
NodeInput(transform,
TransformDistortNode::kTextureInput));
Node::ConnectEdge(transform,
NodeInput(block,
ClipBlock::kBufferIn));
block->SetNodePositionInContext(transform,
QPointF(-1, 0));
} else {
VolumeNode *volume_node = new VolumeNode();
volume_node->setParent(sequence->parent());
Node::ConnectEdge(
probed_item,
NodeInput(volume_node,
VolumeNode::kSamplesInput));
Node::ConnectEdge(volume_node,
NodeInput(block,
ClipBlock::kBufferIn));
block->SetNodePositionInContext(volume_node,
QPointF(-1, 0));
}
}
}
clips_done++;
emit ProgressChanged(clips_done / number_of_clips);
}
}
}
project_->moveToThread(qApp->thread());
return true;
}
}
#endif // USE_OTIO
+47
View File
@@ -0,0 +1,47 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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/>.
***/
#ifndef OAK_OTIODECODER_H
#define OAK_OTIODECODER_H
#ifdef USE_OTIO
#include "common/otioutils.h"
#include "node/project.h"
#include "task/project/load/loadbasetask.h"
namespace olive
{
class LoadOTIOTask : public ProjectLoadBaseTask {
Q_OBJECT
public:
LoadOTIOTask(const QString &filename);
protected:
virtual bool Run() override;
};
}
#endif
#endif // OAK_OTIODECODER_H
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 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}
task/project/save/save.h
task/project/save/save.cpp
PARENT_SCOPE
)
+88
View File
@@ -0,0 +1,88 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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 "save.h"
#include <QDir>
#include <QFile>
#include <QXmlStreamWriter>
#include "common/filefunctions.h"
#include "node/project/serializer/serializer.h"
namespace olive
{
ProjectSaveTask::ProjectSaveTask(Project *project, bool use_compression)
: project_(project)
, use_compression_(use_compression)
{
set_title(tr("Saving '%1'").arg(project->filename()));
}
bool ProjectSaveTask::run()
{
QString using_filename = override_filename_.isEmpty() ?
project_->filename() :
override_filename_;
ProjectSerializer::SaveData data(ProjectSerializer::k_project);
data.set_filename(using_filename);
data.set_project(project_);
data.set_layout(layout_);
ProjectSerializer::Result result =
ProjectSerializer::save(data, use_compression_);
bool success = false;
switch (result.code()) {
case ProjectSerializer::k_success:
success = true;
break;
case ProjectSerializer::k_xml_error:
set_error(tr("Failed to write XML data."));
break;
case ProjectSerializer::k_file_error:
set_error(tr("Failed to open file \"%1\" for writing.")
.arg(result.get_details()));
break;
case ProjectSerializer::k_overwrite_error:
set_error(
tr("Failed to overwrite \"%1\". Project has been saved as \"%2\" instead.")
.arg(using_filename, result.get_details()));
success = true;
break;
// Errors that should never be thrown by a save
case ProjectSerializer::k_project_too_new:
case ProjectSerializer::k_project_too_old:
case ProjectSerializer::k_unknown_version:
case ProjectSerializer::k_no_data:
set_error(tr("Unknown error."));
break;
}
return success;
}
}
+67
View File
@@ -0,0 +1,67 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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/>.
***/
#ifndef OAK_PROJECTSAVEMANAGER_H
#define OAK_PROJECTSAVEMANAGER_H
#include "node/project.h"
#include "node/project/serializer/mainwindowlayoutinfo.h"
#include "task/task.h"
namespace olive
{
class ProjectSaveTask : public Task {
Q_OBJECT
public:
ProjectSaveTask(Project *project, bool use_compression);
Project *get_project() const
{
return project_;
}
void set_override_filename(const QString &filename)
{
override_filename_ = filename;
}
void set_layout(const MainWindowLayoutInfo &layout)
{
layout_ = layout;
}
protected:
virtual bool run() override;
private:
Project *project_;
QString override_filename_;
bool use_compression_;
MainWindowLayoutInfo layout_;
};
}
#endif // OAK_PROJECTSAVEMANAGER_H
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 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}
task/project/saveotio/saveotio.h
task/project/saveotio/saveotio.cpp
PARENT_SCOPE
)
+278
View File
@@ -0,0 +1,278 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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 "saveotio.h"
#ifdef USE_OTIO
#include <opentimelineio/clip.h>
#include <opentimelineio/externalReference.h>
#include <opentimelineio/gap.h>
#include <opentimelineio/serializableCollection.h>
#include <opentimelineio/serializableObject.h>
#include <opentimelineio/transition.h>
#include "node/block/clip/clip.h"
#include "node/block/gap/gap.h"
#include "node/block/transition/transition.h"
#include "node/project/footage/footage.h"
namespace olive
{
SaveOTIOTask::SaveOTIOTask(Project *project)
: project_(project)
{
SetTitle(tr("Exporting project to OpenTimelineIO"));
}
bool SaveOTIOTask::Run()
{
QVector<Sequence *> sequences =
project_->root()->ListChildrenOfType<Sequence>();
if (sequences.isEmpty()) {
SetError(tr("Project contains no sequences to export."));
return false;
}
std::vector<OTIO::SerializableObject *> serialized;
foreach (Sequence *seq, sequences) {
auto otio_timeline = SerializeTimeline(seq);
if (otio_timeline) {
// Append to list
serialized.push_back(otio_timeline);
} else {
// Delete all existing timelines
foreach (auto s, serialized) {
s->possibly_delete();
}
// Error out of function
SetError(
tr("Failed to serialize sequence \"%1\"").arg(seq->GetLabel()));
return false;
}
}
OTIO::ErrorStatus es;
if (serialized.size() == 1) {
// Serialize timeline on its own
auto t = serialized.front();
t->to_json_file(project_->filename().toStdString(), &es);
t->possibly_delete();
} else {
// Serialize all into a SerializableCollection
auto collection =
new OTIO::SerializableCollection("Sequences", serialized);
collection->to_json_file(project_->filename().toStdString(), &es);
collection->possibly_delete();
// Delete all existing timelines
foreach (auto s, serialized) {
s->possibly_delete();
}
}
return (es.outcome == OTIO::ErrorStatus::Outcome::OK);
}
OTIO::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence)
{
auto otio_timeline = new OTIO::Timeline(sequence->GetLabel().toStdString());
// Retainers clean themselves up when the final user is removed
OTIO::Timeline::Retainer<OTIO::Timeline> *timeline_retainer =
new OTIO::Timeline::Retainer<OTIO::Timeline>(otio_timeline);
// Suppress unused variable warning
Q_UNUSED(timeline_retainer);
double rate = sequence->GetVideoParams().frame_rate().toDouble();
if (qIsNaN(rate)) {
return nullptr;
}
if (!SerializeTrackList(sequence->track_list(Track::kVideo), otio_timeline,
rate) ||
!SerializeTrackList(sequence->track_list(Track::kAudio), otio_timeline,
rate)) {
otio_timeline->possibly_delete();
return nullptr;
}
return otio_timeline;
}
OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track, double sequence_rate,
Rational max_track_length)
{
auto otio_track = new OTIO::Track();
OTIO::ErrorStatus es;
switch (track->type()) {
case Track::kVideo:
otio_track->set_kind("Video");
break;
case Track::kAudio:
otio_track->set_kind("Audio");
break;
default:
qWarning()
<< "Don't know OTIO track kind for native type" << track->type();
goto fail;
}
foreach (Block *block, track->Blocks()) {
OTIO::Composable *otio_block = nullptr;
if (dynamic_cast<ClipBlock *>(block)) {
auto otio_clip = new OTIO::Clip(block->GetLabel().toStdString());
otio_clip->set_source_range(
OTIO::TimeRange(block->in().toRationalTime(sequence_rate),
block->length().toRationalTime(sequence_rate)));
QVector<Footage *> media_nodes = block->FindInputNodes<Footage>();
if (!media_nodes.isEmpty()) {
OTIO::TimeRange available_range;
if (otio_track->kind().compare("Video") == 0) {
// OTIO ExternalReference uses the source clips frame rate (or sample rate) as opposed to
// the sequences rate
double source_frame_rate = static_cast<ClipBlock *>(block)
->connected_viewer()
->GetVideoParams()
.frame_rate()
.toDouble();
available_range = OTIO::TimeRange(
OTIO::RationalTime(0, source_frame_rate),
OTIO::RationalTime(
media_nodes.first()->GetVideoParams().duration(),
source_frame_rate));
} else if (otio_track->kind().compare("Audio") == 0) {
available_range = OTIO::TimeRange(
OTIO::RationalTime(
0,
media_nodes.first()->GetAudioParams().sample_rate()),
OTIO::RationalTime(
media_nodes.first()->GetAudioParams().duration(),
media_nodes.first()->GetAudioParams().sample_rate()));
}
auto media_ref = new OTIO::ExternalReference(
media_nodes.first()->filename().toStdString(),
available_range);
otio_clip->set_media_reference(media_ref);
}
otio_block = otio_clip;
} else if (dynamic_cast<GapBlock *>(block)) {
otio_block =
new OTIO::Gap(OTIO::TimeRange(block->in().toRationalTime(),
block->length().toRationalTime()),
block->GetLabel().toStdString());
} else if (dynamic_cast<TransitionBlock *>(block)) {
auto otio_transition =
new OTIO::Transition(block->GetLabel().toStdString());
TransitionBlock *our_transition =
static_cast<TransitionBlock *>(block);
otio_transition->set_in_offset(
our_transition->in_offset().toRationalTime());
otio_transition->set_out_offset(
our_transition->out_offset().toRationalTime());
otio_block = new OTIO::Transition();
}
if (!otio_block) {
// We shouldn't ever get here, but catch without crashing if we ever do
goto fail;
}
otio_track->append_child(otio_block, &es);
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
goto fail;
}
}
// All OTIO tracks must have the same duration so we add a Gap to fill the remaining time
if (otio_track->duration(&es).to_seconds() < max_track_length.toDouble()) {
double time_left = max_track_length.toDouble() -
otio_track->duration(&es).to_seconds();
OTIO::Gap *gap = new OTIO::Gap(OTIO::TimeRange(
otio_track->duration(&es), OTIO::RationalTime(time_left, 1.0)));
otio_track->append_child(gap, &es);
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
goto fail;
}
}
return otio_track;
fail:
otio_track->possibly_delete();
return nullptr;
}
bool SaveOTIOTask::SerializeTrackList(TrackList *list,
OTIO::Timeline *otio_timeline,
double sequence_rate)
{
OTIO::ErrorStatus es;
Rational max_track_length = RATIONAL_MIN;
foreach (Track *track, list->GetTracks()) {
if (track->track_length() > max_track_length) {
max_track_length = track->track_length();
}
}
foreach (Track *track, list->GetTracks()) {
auto otio_track =
SerializeTrack(track, sequence_rate, max_track_length);
if (!otio_track) {
return false;
}
otio_timeline->tracks()->append_child(otio_track, &es);
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
otio_track->possibly_delete();
return false;
}
}
return true;
}
}
#endif // USE_OTIO
+61
View File
@@ -0,0 +1,61 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
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/>.
***/
#ifndef OAK_PROJECTSAVEASOTIOTASK_H
#define OAK_PROJECTSAVEASOTIOTASK_H
#ifdef USE_OTIO
#include <opentimelineio/timeline.h>
#include <opentimelineio/track.h>
#include "common/otioutils.h"
#include "node/project.h"
#include "task/task.h"
namespace olive
{
class SaveOTIOTask : public Task {
Q_OBJECT
public:
SaveOTIOTask(Project *project);
protected:
virtual bool Run() override;
private:
OTIO::Timeline *SerializeTimeline(Sequence *sequence);
OTIO::Track *SerializeTrack(Track *track, double sequence_rate,
Rational max_track_length);
bool SerializeTrackList(TrackList *list, OTIO::Timeline *otio_timeline,
double sequence_rate);
Project *project_;
};
}
#endif
#endif // OAK_PROJECTSAVEASOTIOTASK_H