-
Notifications
You must be signed in to change notification settings - Fork 329
Expand file tree
/
Copy pathbundle.cpp
More file actions
62 lines (53 loc) · 1.58 KB
/
bundle.cpp
File metadata and controls
62 lines (53 loc) · 1.58 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
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenTimelineIO project
// Example for converting an .otio file into a bundle.
#include "util.h"
#include <opentimelineio/bundle.h>
#include <filesystem>
using namespace OTIO_NS;
int
main(int argc, char** argv)
{
if (argc != 3) {
std::cout << "Usage: bundle (input.otio) (output.otioz|output.otiod)" << std::endl;
return 1;
}
const std::string input = examples::normalize_path(argv[1]);
const std::string output = examples::normalize_path(argv[2]);
// Read the timeline
ErrorStatus error_status;
SerializableObject::Retainer<Timeline> timeline(dynamic_cast<Timeline*>(
Timeline::from_json_file(input, &error_status)));
if (!timeline || is_error(error_status)) {
examples::print_error(error_status);
return 1;
}
// Write the bundle
bundle::WriteOptions options;
options.relative_media_path =
std::filesystem::u8path(input).parent_path().u8string();
auto const ext = std::filesystem::u8path(output).extension().u8string();
if (".otiod" == ext)
{
if (!bundle::write_otiod(
timeline,
output,
options,
&error_status)) {
examples::print_error(error_status);
return 1;
}
}
else
{
if (!bundle::write_otioz(
timeline,
output,
options,
&error_status)) {
examples::print_error(error_status);
return 1;
}
}
return 0;
}