@@ -32,13 +32,25 @@ def main():
3232
3333 args = parse_arguments ()
3434
35+ # Special case option, which skips all the other phases
36+
37+ if args .list_versions :
38+ print ("Available versions for --downgrade FAMILY:VERSION" )
39+ for family , mapping in otio .versioning .full_map ().items ():
40+ for label in mapping .keys ():
41+ print (f" { family } :{ label } " )
42+ return
43+
3544 # Phase 1: Input...
3645
3746 # Most of this function will operate on this list of timelines.
3847 # Often there will be just one, but this tool in general enough
3948 # to operate on several. This is essential when the --stack or
4049 # --concatenate arguments are used.
41- timelines = read_inputs (args .input )
50+ if args .input :
51+ timelines = read_inputs (args .input )
52+ else :
53+ timelines = []
4254
4355 # Phase 2: Filter (remove stuff)...
4456
@@ -133,6 +145,13 @@ def main():
133145
134146 # Final Phase: Output
135147
148+ if args .downgrade :
149+ if ":" in args .downgrade :
150+ label = args .downgrade
151+ else :
152+ label = "OTIO_CORE:" + args .downgrade
153+ os .environ ["OTIO_DEFAULT_TARGET_VERSION_FAMILY_LABEL" ] = label
154+
136155 if args .output :
137156 # Gather all of the timelines under one OTIO object
138157 # in preparation for final output
@@ -188,7 +207,8 @@ def parse_arguments():
188207 Finally, if the "--output <filename>" option is specified, the resulting
189208 OTIO will be written to the specified file. The extension of the output
190209 filename is used to determine the format of the output (e.g. OTIO or any
191- format supported by the adapter plugins.)
210+ format supported by the adapter plugins.) If you need to output an older
211+ schema version, see the --downgrade option.
192212""" .strip (),
193213 epilog = """Examples:
194214
@@ -213,7 +233,6 @@ def parse_arguments():
213233 "--input" ,
214234 type = str ,
215235 nargs = '+' ,
216- required = True ,
217236 metavar = 'PATH(s)' ,
218237 help = """Input file path(s). All formats supported by adapter plugins
219238 are supported. Use '-' to read OTIO from standard input."""
@@ -369,6 +388,24 @@ def parse_arguments():
369388 )
370389
371390 # Output...
391+ parser .add_argument (
392+ "--downgrade" ,
393+ type = str ,
394+ metavar = 'FAMILY:VERSION' ,
395+ help = """Downgrade OTIO schema. Only relevant when --output is used
396+ to output an OTIO file. FAMILY:VERSION specifies which schema family
397+ and version to use. If FAMILY: is omitted, the default OTIO_CORE: is
398+ used. For example `--downgrade OTIO_CORE:0.14.0` is equivalent to
399+ `--downgrade 0.14.0`. See
400+ https://opentimelineio.readthedocs.io/en/latest/tutorials/versioning-schemas.html
401+ for details."""
402+ )
403+ parser .add_argument (
404+ "--list-versions" ,
405+ action = 'store_true' ,
406+ help = """List available versions for the --downgrade option."""
407+ )
408+
372409 parser .add_argument (
373410 "-o" ,
374411 "--output" ,
@@ -380,6 +417,10 @@ def parse_arguments():
380417
381418 args = parser .parse_args ()
382419
420+ # At least one of these must be specified
421+ if not any ([args .input , args .list_versions ]):
422+ parser .error ("Must specify at least one of --input or --list-versions." )
423+
383424 # Some options cannot be combined.
384425
385426 if args .video_only and args .audio_only :
@@ -391,6 +432,9 @@ def parse_arguments():
391432 if args .keep_flattened_tracks and not args .flatten :
392433 parser .error ("Cannot use --keep-flattened-tracks without also using --flatten." )
393434
435+ if args .input and args .list_versions :
436+ parser .error ("Cannot combine --input and --list-versions." )
437+
394438 return args
395439
396440
0 commit comments