@@ -32,13 +32,25 @@ def main():
32
32
33
33
args = parse_arguments ()
34
34
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
+
35
44
# Phase 1: Input...
36
45
37
46
# Most of this function will operate on this list of timelines.
38
47
# Often there will be just one, but this tool in general enough
39
48
# to operate on several. This is essential when the --stack or
40
49
# --concatenate arguments are used.
41
- timelines = read_inputs (args .input )
50
+ if args .input :
51
+ timelines = read_inputs (args .input )
52
+ else :
53
+ timelines = []
42
54
43
55
# Phase 2: Filter (remove stuff)...
44
56
@@ -133,6 +145,13 @@ def main():
133
145
134
146
# Final Phase: Output
135
147
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
+
136
155
if args .output :
137
156
# Gather all of the timelines under one OTIO object
138
157
# in preparation for final output
@@ -188,7 +207,8 @@ def parse_arguments():
188
207
Finally, if the "--output <filename>" option is specified, the resulting
189
208
OTIO will be written to the specified file. The extension of the output
190
209
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.
192
212
""" .strip (),
193
213
epilog = """Examples:
194
214
@@ -213,7 +233,6 @@ def parse_arguments():
213
233
"--input" ,
214
234
type = str ,
215
235
nargs = '+' ,
216
- required = True ,
217
236
metavar = 'PATH(s)' ,
218
237
help = """Input file path(s). All formats supported by adapter plugins
219
238
are supported. Use '-' to read OTIO from standard input."""
@@ -369,6 +388,24 @@ def parse_arguments():
369
388
)
370
389
371
390
# 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
+
372
409
parser .add_argument (
373
410
"-o" ,
374
411
"--output" ,
@@ -380,6 +417,10 @@ def parse_arguments():
380
417
381
418
args = parser .parse_args ()
382
419
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
+
383
424
# Some options cannot be combined.
384
425
385
426
if args .video_only and args .audio_only :
@@ -391,6 +432,9 @@ def parse_arguments():
391
432
if args .keep_flattened_tracks and not args .flatten :
392
433
parser .error ("Cannot use --keep-flattened-tracks without also using --flatten." )
393
434
435
+ if args .input and args .list_versions :
436
+ parser .error ("Cannot combine --input and --list-versions." )
437
+
394
438
return args
395
439
396
440
0 commit comments