mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #1393 from ynput/bugfix/detect_rounding_available_range
Detect rounding issues in media available_range when extracting (OTIO).
This commit is contained in:
commit
f137ea3954
3 changed files with 45 additions and 7 deletions
|
|
@ -7,6 +7,10 @@ import opentimelineio as otio
|
|||
from opentimelineio import opentime as _ot
|
||||
|
||||
|
||||
# https://github.com/AcademySoftwareFoundation/OpenTimelineIO/issues/1822
|
||||
OTIO_EPSILON = 1e-9
|
||||
|
||||
|
||||
def otio_range_to_frame_range(otio_range):
|
||||
start = _ot.to_frames(
|
||||
otio_range.start_time, otio_range.start_time.rate)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from ayon_core.lib import (
|
|||
get_ffmpeg_tool_args,
|
||||
run_subprocess
|
||||
)
|
||||
from ayon_core.pipeline import editorial
|
||||
|
||||
|
||||
class ExtractOtioAudioTracks(pyblish.api.ContextPlugin):
|
||||
|
|
@ -172,6 +173,14 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin):
|
|||
clip_start = otio_clip.source_range.start_time
|
||||
fps = clip_start.rate
|
||||
conformed_av_start = media_av_start.rescaled_to(fps)
|
||||
|
||||
# Avoid rounding issue on media available range.
|
||||
if clip_start.almost_equal(
|
||||
conformed_av_start,
|
||||
editorial.OTIO_EPSILON
|
||||
):
|
||||
conformed_av_start = clip_start
|
||||
|
||||
# ffmpeg ignores embedded tc
|
||||
start = clip_start - conformed_av_start
|
||||
duration = otio_clip.source_range.duration
|
||||
|
|
|
|||
|
|
@ -23,7 +23,11 @@ from ayon_core.lib import (
|
|||
get_ffmpeg_tool_args,
|
||||
run_subprocess,
|
||||
)
|
||||
from ayon_core.pipeline import publish
|
||||
from ayon_core.pipeline import (
|
||||
KnownPublishError,
|
||||
editorial,
|
||||
publish,
|
||||
)
|
||||
|
||||
|
||||
class ExtractOTIOReview(
|
||||
|
|
@ -97,8 +101,11 @@ class ExtractOTIOReview(
|
|||
|
||||
# skip instance if no reviewable data available
|
||||
if (
|
||||
not isinstance(otio_review_clips[0], otio.schema.Clip)
|
||||
and len(otio_review_clips) == 1
|
||||
len(otio_review_clips) == 1
|
||||
and (
|
||||
not isinstance(otio_review_clips[0], otio.schema.Clip)
|
||||
or otio_review_clips[0].media_reference.is_missing_reference
|
||||
)
|
||||
):
|
||||
self.log.warning(
|
||||
"Instance `{}` has nothing to process".format(instance))
|
||||
|
|
@ -248,7 +255,7 @@ class ExtractOTIOReview(
|
|||
|
||||
# Single video way.
|
||||
# Extraction via FFmpeg.
|
||||
else:
|
||||
elif hasattr(media_ref, "target_url"):
|
||||
path = media_ref.target_url
|
||||
# Set extract range from 0 (FFmpeg ignores
|
||||
# embedded timecode).
|
||||
|
|
@ -370,6 +377,13 @@ class ExtractOTIOReview(
|
|||
|
||||
avl_start = avl_range.start_time
|
||||
|
||||
# Avoid rounding issue on media available range.
|
||||
if start.almost_equal(
|
||||
avl_start,
|
||||
editorial.OTIO_EPSILON
|
||||
):
|
||||
avl_start = start
|
||||
|
||||
# An additional gap is required before the available
|
||||
# range to conform source start point and head handles.
|
||||
if start < avl_start:
|
||||
|
|
@ -388,6 +402,14 @@ class ExtractOTIOReview(
|
|||
# (media duration is shorter then clip requirement).
|
||||
end_point = start + duration
|
||||
avl_end_point = avl_range.end_time_exclusive()
|
||||
|
||||
# Avoid rounding issue on media available range.
|
||||
if end_point.almost_equal(
|
||||
avl_end_point,
|
||||
editorial.OTIO_EPSILON
|
||||
):
|
||||
avl_end_point = end_point
|
||||
|
||||
if end_point > avl_end_point:
|
||||
gap_duration = end_point - avl_end_point
|
||||
duration -= gap_duration
|
||||
|
|
@ -444,7 +466,7 @@ class ExtractOTIOReview(
|
|||
command = get_ffmpeg_tool_args("ffmpeg")
|
||||
|
||||
input_extension = None
|
||||
if sequence:
|
||||
if sequence is not None:
|
||||
input_dir, collection, sequence_fps = sequence
|
||||
in_frame_start = min(collection.indexes)
|
||||
|
||||
|
|
@ -478,7 +500,7 @@ class ExtractOTIOReview(
|
|||
"-i", input_path
|
||||
])
|
||||
|
||||
elif video:
|
||||
elif video is not None:
|
||||
video_path, otio_range = video
|
||||
frame_start = otio_range.start_time.value
|
||||
input_fps = otio_range.start_time.rate
|
||||
|
|
@ -496,7 +518,7 @@ class ExtractOTIOReview(
|
|||
"-i", video_path
|
||||
])
|
||||
|
||||
elif gap:
|
||||
elif gap is not None:
|
||||
sec_duration = frames_to_seconds(gap, self.actual_fps)
|
||||
|
||||
# form command for rendering gap files
|
||||
|
|
@ -510,6 +532,9 @@ class ExtractOTIOReview(
|
|||
"-tune", "stillimage"
|
||||
])
|
||||
|
||||
else:
|
||||
raise KnownPublishError("Sequence, video or gap is required.")
|
||||
|
||||
if video or sequence:
|
||||
command.extend([
|
||||
"-vf", f"scale={self.to_width}:{self.to_height}:flags=lanczos",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue