Jaded-Encoding-Thaumaturgy / vs-preview

Previewer for VapourSynth scripts.
Apache License 2.0
57 stars 16 forks source link

Variable frame-rate (VFR) clip support is broken #116

Closed JustinTArthur closed 8 months ago

JustinTArthur commented 9 months ago

Given a VFR clip with _DurationDen and _DurationNum properly filled out, attempting to preview an output of the clip in vs-preview results in an exception, and an overall failure to load the script hosting the output.

The first issue:

Traceback (most recent call last):
  File "vspreview/main/window.py", line 392, in load_script
    self.load_storage()
  File "vspreview/utils/utils.py", line 87, in _wrapped
    ret = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "vspreview/main/window.py", line 464, in load_storage
    loader.get_single_data()
  File "yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 60, in construct_document
    for dummy in generator:
  File "yaml/constructor.py", line 620, in construct_python_object
    state = self.construct_mapping(node, deep=deep)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 143, in construct_mapping
    value = self.construct_object(value_node, deep=deep)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 107, in construct_object
    for dummy in generator:
  File "yaml/constructor.py", line 413, in construct_yaml_map
    value = self.construct_mapping(node)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 218, in construct_mapping
    return super().construct_mapping(node, deep=deep)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 143, in construct_mapping
    value = self.construct_object(value_node, deep=deep)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 107, in construct_object
    for dummy in generator:
  File "yaml/constructor.py", line 621, in construct_python_object
    self.set_python_instance_state(instance, state)
  File "yaml/constructor.py", line 726, in set_python_instance_state
    return super(UnsafeConstructor, self).set_python_instance_state(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "yaml/constructor.py", line 597, in set_python_instance_state
    instance.__setstate__(state)
  File "vspreview/models/outputs.py", line 146, in __setstate__
    self.setValue(main_window(), state)
  File "vspreview/models/outputs.py", line 58, in setValue
    output = self.out_type(vs_output, i, newstorage)  # type: ignore
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vspreview/core/types/video.py", line 93, in __init__
    self.setValue(vs_output, index, new_storage)
  File "vspreview/core/types/video.py", line 187, in setValue
    self.play_fps = self.main.toolbars.playback.get_true_fps(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "vspreview/toolbars/playback/toolbar.py", line 211, in get_true_fps
    raise RuntimeError(
RuntimeError: Playback: DurationDen and DurationNum frame props are needed for VFR clips!

get_true_fps is passed an empty properties dict because no frame has been rendered on the VideoOutput yet; we're still constructing the VideoOutput at this point.

Wrapping it in a try/except and presetting an initial play_fps is insufficient. Other issues are then encountered like playback stopping after the first second, Sync Outputs not syncing, etc.

Setsugennoao commented 9 months ago

Can't reproduce this error.

JustinTArthur commented 9 months ago

@Setsugennoao thanks for giving it a try. Make sure to try with a fresh/reset .vspreview storage so that prior output play_fps is not reused.

Setsugennoao commented 9 months ago

Can't test it now so i'm gonna reopen, since you're prolly right