3131namespace otio = opentimelineio::OPENTIMELINEIO_VERSION_NS;
3232
3333// Look for media with this name in this folder.
34- std::string find_matching_media (std::string const & name, std::string const & folder)
34+ std::string
35+ find_matching_media (std::string const & name, std::string const & folder)
3536{
3637 // This function is an example which searches the file system for matching media.
3738 // A real world studio implementation would likely look in an asset management system
@@ -41,9 +42,9 @@ std::string find_matching_media(std::string const& name, std::string const& fold
4142 // shot = asset_database->find_shot(
4243 // otio::any_cast<std::map<std::string, std::string> >(clip->metadata()["mystudio"])["shotID"]);
4344 // new_media = shot->latest_render("mov");
44-
45+
4546 const auto matches = examples::glob (folder, name + " .*" );
46-
47+
4748 if (matches.size () == 0 )
4849 {
4950 // std::cout << "DEBUG: No match for clip '" << name << "'" << std::endl;
@@ -55,8 +56,9 @@ std::string find_matching_media(std::string const& name, std::string const& fold
5556 }
5657 else
5758 {
58- std::cout << " WARNING: " << matches.size () << " matches found for clip '" <<
59- name << " ', using '" << matches[0 ] << " '" ;
59+ std::cout << " WARNING: " << matches.size ()
60+ << " matches found for clip '" << name << " ', using '"
61+ << matches[0 ] << " '" ;
6062 return matches[0 ];
6163 }
6264}
@@ -70,21 +72,22 @@ std::string find_matching_media(std::string const& name, std::string const& fold
7072// internal reference count. For more details on the usage of Retainers see
7173// the C++ documentation:
7274// https://opentimelineio.readthedocs.io/en/latest/cxx/cxx.html
73- int conform_timeline (
75+ int
76+ conform_timeline (
7477 otio::SerializableObject::Retainer<otio::Timeline> const & timeline,
75- std::string const & folder)
78+ std::string const & folder)
7679{
7780 int count = 0 ;
78-
81+
7982 otio::ErrorStatus error_status;
80- const auto clips = timeline->find_clips (&error_status);
83+ const auto clips = timeline->find_clips (&error_status);
8184 if (otio::is_error (error_status))
8285 {
8386 examples::print_error (error_status);
8487 exit (1 );
8588 }
86-
87- for (const otio::SerializableObject::Retainer<otio::Clip>& clip : clips)
89+
90+ for (const otio::SerializableObject::Retainer<otio::Clip>& clip: clips)
8891 {
8992 // look for a media file that matches the clip's name
9093 const std::string new_path = find_matching_media (clip->name (), folder);
@@ -96,28 +99,31 @@ int conform_timeline(
9699 // relink to the found path
97100 clip->set_media_reference (new otio::ExternalReference (
98101 " file://" + new_path,
99- std::nullopt // the available range is unknown without opening the file
100- ));
102+ std::
103+ nullopt // the available range is unknown without opening the file
104+ ));
101105 count += 1 ;
102106 }
103-
107+
104108 return count;
105109}
106110
107- int main (int argc, char ** argv)
111+ int
112+ main (int argc, char ** argv)
108113{
109114 if (argc != 4 )
110115 {
111116 std::cout << " Usage: conform (input) (folder) (output)" << std::endl;
112117 return 1 ;
113118 }
114- const std::string input = examples::normalize_path (argv[1 ]);
119+ const std::string input = examples::normalize_path (argv[1 ]);
115120 const std::string folder = examples::normalize_path (argv[2 ]);
116121 const std::string output = examples::normalize_path (argv[3 ]);
117-
118- otio::ErrorStatus error_status;
122+
123+ otio::ErrorStatus error_status;
119124 otio::SerializableObject::Retainer<otio::Timeline> timeline (
120- dynamic_cast <otio::Timeline*>(otio::Timeline::from_json_file (input, &error_status)));
125+ dynamic_cast <otio::Timeline*>(
126+ otio::Timeline::from_json_file (input, &error_status)));
121127 if (!timeline || otio::is_error (error_status))
122128 {
123129 examples::print_error (error_status);
@@ -136,7 +142,8 @@ int main(int argc, char** argv)
136142 examples::print_error (error_status);
137143 exit (1 );
138144 }
139- std::cout << " Saved " << output << " with " << clips.size () << " clips." << std::endl;
140-
145+ std::cout << " Saved " << output << " with " << clips.size () << " clips."
146+ << std::endl;
147+
141148 return 0 ;
142149}
0 commit comments