-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
73 lines (61 loc) · 2.5 KB
/
example.cpp
File metadata and controls
73 lines (61 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <stdio.h>
#include <opentimelineio/clip.h>
#include <opentimelineio/timeline.h>
namespace otio = opentimelineio::OPENTIMELINEIO_VERSION;
int main(int argc, char** argv)
{
if (argc < 2) {
std::cerr << "Usage: " << argv[0] << " <file.otio>" << std::endl;
return 1;
}
// This is the file we will load
std::string path(argv[1]);
// Load the timeline into memory
otio::ErrorStatus error_status;
auto timeline = dynamic_cast<otio::Timeline*>(
otio::Timeline::from_json_file(path, &error_status));
// Check for errors
if (!timeline || otio::is_error(error_status)) {
std::cerr << "Error loading: " << path << " : "
<< otio::ErrorStatus::outcome_to_string(error_status.outcome)
<< ": " << error_status.details << std::endl;
return 2;
}
// Display information about what was loaded
std::cout << "Loaded OTIO file: " << path << std::endl
<< "Timeline name: " << timeline->name() << std::endl
<< "Timeline duration: " << timeline->duration().to_timecode()
<< std::endl;
std::cout << "Video Tracks:" << std::endl;
if (timeline->video_tracks().size() == 0) {
std::cout << " No video tracks" << std::endl;
} else {
for (const auto& track : timeline->video_tracks()) {
std::cout << " Track: " << track->name() << std::endl
<< " Kind: " << track->kind() << std::endl
<< " Duration: " << track->duration().to_timecode()
<< std::endl;
}
}
std::cout << "Audio Tracks:" << std::endl;
if (timeline->audio_tracks().size() == 0) {
std::cout << " No audio tracks" << std::endl;
} else {
for (const auto& track : timeline->audio_tracks()) {
std::cout << " Track: " << track->name() << std::endl
<< " Kind: " << track->kind() << std::endl
<< " Duration: " << track->duration().to_timecode()
<< std::endl;
}
}
// Print some info about all the clips in the timeline
// Note: timeline>clip_if() will recurse into all nested compositions
std::cout << "All Clips:" << std::endl;
for (const auto& clip : timeline->clip_if()) {
std::cout << " Clip: " << clip->name() << std::endl
<< " Duration: " << clip->duration().to_timecode()
<< std::endl;
}
return 0;
}