Skip to content

Commit 1b3ece1

Browse files
jminorcato-o
andauthored
Added --remove-effects feature to otiotool. (#1912)
* Added --remove-effects feature to otiotool. * Remove redundant uses of "otio_json" adapter name. Signed-off-by: Joshua Minor <[email protected]> Co-authored-by: Yingjie Wang <[email protected]>
1 parent 639f57c commit 1b3ece1

File tree

3 files changed

+6869
-14
lines changed

3 files changed

+6869
-14
lines changed

src/py-opentimelineio/opentimelineio/console/otiotool.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def main():
6565
if args.remove_transitions:
6666
timelines = filter_transitions(timelines)
6767

68+
if args.remove_effects:
69+
timelines = filter_effects(timelines)
70+
6871
if args.only_tracks_with_name or args.only_tracks_with_index:
6972
timelines = filter_tracks(
7073
args.only_tracks_with_name,
@@ -184,10 +187,10 @@ def parse_arguments():
184187
185188
2. Filtering
186189
Options such as --video-only, --audio-only, --only-tracks-with-name,
187-
-only-tracks-with-index, --only-clips-with-name,
188-
--only-clips-with-name-regex, --remove-transitions, and --trim will remove
189-
content. Only the tracks, clips, etc. that pass all of the filtering options
190-
provided are passed to the next phase.
190+
--only-tracks-with-index, --only-clips-with-name,
191+
--only-clips-with-name-regex, --remove-transitions, --remove-effects and
192+
--trim will remove content. Only the tracks, clips, etc. that pass all of
193+
the filtering options provided are passed to the next phase.
191194
192195
3. Combine
193196
If specified, the --stack, --concat, and --flatten operations are
@@ -295,6 +298,11 @@ def parse_arguments():
295298
action='store_true',
296299
help="Remove all transitions"
297300
)
301+
parser.add_argument(
302+
"--remove-effects",
303+
action='store_true',
304+
help="Remove all effects"
305+
)
298306
parser.add_argument(
299307
"--trim",
300308
"-t",
@@ -501,6 +509,18 @@ def _f(item):
501509
return [otio.algorithms.filtered_composition(t, _f) for t in timelines]
502510

503511

512+
def filter_effects(timelines):
513+
"""Remove all effects from the input timelines. The inputs are modified
514+
in place, and also returned."""
515+
for timeline in timelines:
516+
# Items have an effects attribute, but other Composables do not.
517+
# (e.g. Transitions) so we need to find only Items.
518+
for item in timeline.find_children(descended_from_type=otio.core.Item):
519+
# Clear the effects list contents
520+
item.effects[:] = []
521+
return timelines
522+
523+
504524
def _filter(item, names, patterns):
505525
"""This is a helper function that returns the input item if
506526
its name matches the list of names given (if any), or matches any of the

0 commit comments

Comments
 (0)