From 133bb32c8154234761b6e798528d41a121f275ea Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Wed, 22 Jan 2025 20:52:15 +0100 Subject: [PATCH] Fix lint. --- client/ayon_core/pipeline/editorial.py | 30 ++++++++++++++----- .../test_media_range_with_retimes.py | 10 +++---- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/client/ayon_core/pipeline/editorial.py b/client/ayon_core/pipeline/editorial.py index 434fff0105..2ecc786581 100644 --- a/client/ayon_core/pipeline/editorial.py +++ b/client/ayon_core/pipeline/editorial.py @@ -398,7 +398,10 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end): if is_input_sequence: src_in = conformed_source_range.start_time - src_duration = math.ceil(otio_clip.source_range.duration.value * abs(time_scalar)) + src_duration = math.ceil( + otio_clip.source_range.duration.value + * abs(time_scalar) + ) retimed_duration = otio.opentime.RationalTime( src_duration, otio_clip.source_range.duration.rate @@ -422,9 +425,15 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end): # compute retimed range media_in_trimmed = conformed_source_range.start_time.value + offset_in - offset_duration = conformed_source_range.duration.value * abs(time_scalar) - offset_duration -= 1 # duration 1 frame -> freeze frame -> end = start + 0 - offset_duration = max(0, offset_duration) # negative duration = frozen frame + offset_duration = ( + conformed_source_range.duration.value + * abs(time_scalar) + ) + + # duration 1 frame -> freeze frame -> end = start + 0 + offset_duration -= 1 + # negative duration = frozen frame + offset_duration = max(0, offset_duration) media_out_trimmed = media_in_trimmed + offset_duration media_in = available_range.start_time.value @@ -443,17 +452,22 @@ def get_media_range_with_retimes(otio_clip, handle_start, handle_end): for idx, frame_number in enumerate(frame_range): # First timewarp, apply on media range if tw_idx == 0: - frame_range[idx] = round(frame_number + tw["lookup"][idx] * time_scalar) + frame_range[idx] = round( + frame_number + + (tw["lookup"][idx] * time_scalar) + ) # Consecutive timewarp, apply on the previous result else: new_idx = round(idx + tw["lookup"][idx]) if not 0 <= new_idx < len(frame_range): # TODO: implementing this would need to actually have - # retiming engine resolve process within AYON, resolving wraps - # as curves, then projecting those into the previous media_range. + # retiming engine resolve process within AYON, + # resolving wraps as curves, then projecting + # those into the previous media_range. raise NotImplementedError( - "Unsupported consecutive timewarps (out of computed range)" + "Unsupported consecutive timewarps " + "(out of computed range)" ) frame_range[idx] = frame_range[new_idx] diff --git a/tests/client/ayon_core/pipeline/editorial/test_media_range_with_retimes.py b/tests/client/ayon_core/pipeline/editorial/test_media_range_with_retimes.py index ab67d49e22..fbab60623f 100644 --- a/tests/client/ayon_core/pipeline/editorial/test_media_range_with_retimes.py +++ b/tests/client/ayon_core/pipeline/editorial/test_media_range_with_retimes.py @@ -501,7 +501,7 @@ def test_img_sequence_2x_speed_resolve(): """ Img sequence clip available files = 0-99 24fps - source_range = 38-49 24fps + source_range = 38-49 24fps speed = 2.0 """ expected_data = { @@ -531,7 +531,7 @@ def test_img_sequence_frozen_frame(): """ Img sequence clip available files = 948674-948974 25fps - source_range = 909990.8339241028 + source_range = 909990.8339241028 - 909995.8339241028 23.976fps speed = 0.0 """ @@ -562,7 +562,7 @@ def test_img_sequence_timewarp_beyond_range(): """ Img sequence clip available files = 948674-948974 25fps - source_range = 909990.8339241028 + source_range = 909990.8339241028 - 909995.8339241028 23.976fps timewarp to get from 948845 to 948870 """ @@ -611,7 +611,7 @@ def test_img_sequence_2X_speed_timewarp(): """ Img sequence clip available files = 948674-948974 25fps - source_range = 909990.8339241028 + source_range = 909990.8339241028 - 909995.8339241028 23.976fps speed: 200% timewarp to get from 948854 to 948874 @@ -662,7 +662,7 @@ def test_img_sequence_multiple_timewarps(): """ Img sequence clip available files = 948674-948974 25fps - source_range = 909990.8339241028 + source_range = 909990.8339241028 - 909995.8339241028 23.976fps multiple timewarps to get from 948842 to 948864 """