OpenTimelineIO icon indicating copy to clipboard operation
OpenTimelineIO copied to clipboard

SVG Adapter erroneously assumes `media_reference` always has `target_url`

Open jlskuz opened this issue 3 years ago • 3 comments

Bug Report

Incorrect Functionality and General Questions

(@KarthikRIyer) The SVG Adapter erroneously assumes media_reference always has target_url. Eg. GeneratorReference does not have target_url

To Reproduce

This can be reproduced with any otio (like test.otio.zip that has a media_reference with "OTIO_SCHEMA": "GeneratorReference.1"

Run otioconvert -i test.otio -o test.svg and you will get the output in the Logs section.

OS: Linux KDE Neon (Ubunt) Python: 3.8.10 OpenTimelineIO: 0.14.1

Expected Behavior

otioconvert -i test.otio -o test.svg should create test.svg instead of showing the error

Logs

Traceback (most recent call last):
  File "/home/julius/.local/bin/otioconvert", line 8, in <module>
    sys.exit(main())
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/console/otioconvert.py", line 298, in main
    otio.adapters.write_to_file(
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/adapters/__init__.py", line 194, in write_to_file
    return adapter.write_to_file(
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/adapters/adapter.py", line 212, in write_to_file
    result = self.write_to_string(input_otio, **adapter_argument_map)
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/adapters/adapter.py", line 303, in write_to_string
    return self._execute_function(
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/plugins/python_plugin.py", line 174, in _execute_function
    return (getattr(self.module(), func_name)(**kwargs))
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/adapters/svg.py", line 1137, in write_to_string
    return convert_otio_to_svg(input_otio, width=width, height=height)
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/adapters/svg.py", line 1127, in convert_otio_to_svg
    draw_item(timeline, svg_writer, ())
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/adapters/svg.py", line 548, in draw_item
    return WRITE_TYPE_MAP[type(otio_obj)](otio_obj, svg_writer, extra_data)
  File "/home/julius/.local/lib/python3.8/site-packages/opentimelineio/adapters/svg.py", line 590, in _draw_timeline
    item.media_reference.target_url, clip_count - 1)
AttributeError: 'opentimelineio._otio.GeneratorReference' object has no attribute 'target_url'

Additional Context

Add any other context about the problem here.

jlskuz avatar Dec 16 '21 00:12 jlskuz

Thanks for reporting this! I'm currently out of station. I'll take a look at this once I'm back.

KarthikRIyer avatar Dec 17 '21 16:12 KarthikRIyer

@KarthikRIyer, skimming through the adapter, it seems to not support ImageSequenceReference either which might cause a similar error down the road.

Instead of target_url it has an abstract_target_url() method which produces a full path if you provide a frame number abstraction like: "%04d", "#" and so on.

apetrynet avatar Dec 17 '21 17:12 apetrynet

@apetrynet noted the need for ImageSequenceReference support in #1196

I was looking into this issue. The svg adapter doesn't seem to work well with audio tracks. That's something that needs some investigation.

It also failed for transitions at the end of the track. I've pushed a fix for that in #1195.

There are three transitions, at the same place, in the test otio file. Is that a valid scenario? otioview too shows only the last transition.

KarthikRIyer avatar Jan 16 '22 14:01 KarthikRIyer