Merge branch 'master' into OTIO_load

This commit is contained in:
ThomasWilshaw
2022-01-06 13:56:08 +00:00
committed by GitHub
195 changed files with 11848 additions and 9102 deletions
+6 -5
View File
@@ -36,6 +36,8 @@ ExportTask::ExportTask(ViewerOutput *viewer_node,
// Adjust video params to have no divider
VideoParams vp = viewer_node->GetVideoParams();
vp.set_divider(1);
vp.set_time_base(params.video_params().time_base());
vp.set_frame_rate(params.video_params().frame_rate());
set_video_params(vp);
set_audio_params(viewer_node->GetAudioParams());
@@ -85,15 +87,14 @@ bool ExportTask::Run()
if (params_.video_enabled()) {
// If a transformation matrix is applied to this video, create it here
VideoParams vp = viewer()->GetVideoParams();
if (vp.width() != params_.video_params().width()
|| params_.video_params().height() != params_.video_params().height()) {
if (video_params().width() != params_.video_params().width()
|| video_params().height() != params_.video_params().height()) {
video_force_size = QSize(params_.video_params().width(), params_.video_params().height());
if (params_.video_scaling_method() != ExportParams::kStretch) {
video_force_matrix = ExportParams::GenerateMatrix(params_.video_scaling_method(),
vp.width(),
vp.height(),
video_params().width(),
video_params().height(),
params_.video_params().width(),
params_.video_params().height());
}
+9 -9
View File
@@ -60,7 +60,7 @@ bool LoadOTIOTask::Run()
auto root = OTIO::SerializableObjectWithMetadata::from_json_file(GetFilename().toStdString(), &es);
if (es != OTIO::ErrorStatus::OK) {
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
SetError(tr("Failed to load OpenTimelineIO from file \"%1\"").arg(GetFilename()));
return false;
}
@@ -156,7 +156,7 @@ bool LoadOTIOTask::Run()
// Get clips from track
auto clip_map = otio_track->children();
if (es != OTIO::ErrorStatus::OK) {
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
SetError(tr("Failed to load clip"));
return false;
}
@@ -233,7 +233,7 @@ bool LoadOTIOTask::Run()
block->setParent(sequence->parent());
// Position transition in its own context
sequence->parent()->SetNodePosition(block, block, QPointF(0, 0));
block->SetNodePositionInContext(block, QPointF(0, 0));
}
if (otio_block->schema_name() == "Gap") {
@@ -241,7 +241,7 @@ bool LoadOTIOTask::Run()
block->setParent(sequence->parent());
// Position transition in its own context
sequence->parent()->SetNodePosition(block, block, QPointF(0, 0));
block->SetNodePositionInContext(block, QPointF(0, 0));
}
// Update this after it's used but before any continue statements
@@ -269,7 +269,7 @@ bool LoadOTIOTask::Run()
QFileInfo info(probed_item->filename());
probed_item->SetLabel(info.fileName());
FolderAddChild add(sequence_footage, probed_item, true);
FolderAddChild add(sequence_footage, probed_item);
add.redo_now();
}
@@ -277,10 +277,10 @@ bool LoadOTIOTask::Run()
block->setParent(sequence->parent());
// Position clip in its own context
sequence->parent()->SetNodePosition(block, block, QPointF(0, 0));
block->SetNodePositionInContext(block, QPointF(0, 0));
// Position footage in its context
sequence->parent()->SetNodePosition(probed_item, block, QPointF(-2, 0));
block->SetNodePositionInContext(probed_item, QPointF(-2, 0));
if (track->type() == Track::kVideo) {
@@ -289,14 +289,14 @@ bool LoadOTIOTask::Run()
Node::ConnectEdge(probed_item, NodeInput(transform, TransformDistortNode::kTextureInput));
Node::ConnectEdge(transform, NodeInput(block, ClipBlock::kBufferIn));
sequence->parent()->SetNodePosition(transform, block, QPointF(-1, 0));
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));
sequence->parent()->SetNodePosition(volume_node, block, QPointF(-1, 0));
block->SetNodePositionInContext(volume_node, QPointF(-1, 0));
}
}
}
+51 -11
View File
@@ -91,7 +91,7 @@ bool SaveOTIOTask::Run()
}
}
return (es == OTIO::ErrorStatus::OK);
return (es.outcome == OTIO::ErrorStatus::Outcome::OK);
}
OTIO::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence)
@@ -102,8 +102,13 @@ OTIO::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence)
// Suppress unused variable warning
Q_UNUSED(timeline_retainer);
if (!SerializeTrackList(sequence->track_list(Track::kVideo), otio_timeline)
|| !SerializeTrackList(sequence->track_list(Track::kAudio), otio_timeline)) {
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;
}
@@ -111,7 +116,7 @@ OTIO::Timeline *SaveOTIOTask::SerializeTimeline(Sequence *sequence)
return otio_timeline;
}
OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track)
OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track, double sequence_rate, rational max_track_length)
{
auto otio_track = new OTIO::Track();
@@ -135,12 +140,26 @@ OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track)
if (dynamic_cast<ClipBlock*>(block)) {
auto otio_clip = new OTIO::Clip(block->GetLabel().toStdString());
otio_clip->set_source_range(OTIO::TimeRange(block->in().toRationalTime(),
block->length().toRationalTime()));
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()) {
auto media_ref = new OTIO::ExternalReference(media_nodes.first()->filename().toStdString());
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);
}
@@ -168,7 +187,20 @@ OTIO::Track *SaveOTIOTask::SerializeTrack(Track *track)
otio_track->append_child(otio_block, &es);
if (es != OTIO::ErrorStatus::OK) {
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;
}
}
@@ -181,12 +213,20 @@ fail:
return nullptr;
}
bool SaveOTIOTask::SerializeTrackList(TrackList *list, OTIO::Timeline* otio_timeline)
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()) {
auto otio_track = SerializeTrack(track);
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;
@@ -194,7 +234,7 @@ bool SaveOTIOTask::SerializeTrackList(TrackList *list, OTIO::Timeline* otio_time
otio_timeline->tracks()->append_child(otio_track, &es);
if (es != OTIO::ErrorStatus::OK) {
if (es.outcome != OTIO::ErrorStatus::Outcome::OK) {
otio_track->possibly_delete();
return false;
}
+2 -2
View File
@@ -44,9 +44,9 @@ protected:
private:
OTIO::Timeline* SerializeTimeline(Sequence* sequence);
OTIO::Track* SerializeTrack(Track* track);
OTIO::Track* SerializeTrack(Track* track, double sequence_rate, rational max_track_length);
bool SerializeTrackList(TrackList* list, OTIO::Timeline *otio_timeline);
bool SerializeTrackList(TrackList* list, OTIO::Timeline *otio_timeline, double sequence_rate);
Project* project_;