mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Fix audio extraction from OTIO timeline.
This commit is contained in:
parent
923355cf08
commit
1c7ab66246
1 changed files with 20 additions and 22 deletions
|
|
@ -71,20 +71,17 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin):
|
||||||
name = inst.data["folderPath"]
|
name = inst.data["folderPath"]
|
||||||
|
|
||||||
recycling_file = [f for f in created_files if name in f]
|
recycling_file = [f for f in created_files if name in f]
|
||||||
|
audio_clip = inst.data["otioClip"]
|
||||||
# frameranges
|
audio_range = audio_clip.range_in_parent()
|
||||||
timeline_in_h = inst.data["clipInH"]
|
duration = audio_range.duration.to_frames()
|
||||||
timeline_out_h = inst.data["clipOutH"]
|
|
||||||
fps = inst.data["fps"]
|
|
||||||
|
|
||||||
# create duration
|
|
||||||
duration = (timeline_out_h - timeline_in_h) + 1
|
|
||||||
|
|
||||||
# ffmpeg generate new file only if doesn't exists already
|
# ffmpeg generate new file only if doesn't exists already
|
||||||
if not recycling_file:
|
if not recycling_file:
|
||||||
# convert to seconds
|
parent_track = audio_clip.parent()
|
||||||
start_sec = float(timeline_in_h / fps)
|
parent_track_start = parent_track.range_in_parent().start_time
|
||||||
duration_sec = float(duration / fps)
|
relative_start_time = audio_range.start_time - parent_track_start
|
||||||
|
start_sec = relative_start_time.to_seconds()
|
||||||
|
duration_sec = audio_range.duration.to_seconds()
|
||||||
|
|
||||||
# temp audio file
|
# temp audio file
|
||||||
audio_fpath = self.create_temp_file(name)
|
audio_fpath = self.create_temp_file(name)
|
||||||
|
|
@ -163,9 +160,7 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin):
|
||||||
|
|
||||||
output = []
|
output = []
|
||||||
# go trough all audio tracks
|
# go trough all audio tracks
|
||||||
for otio_track in otio_timeline.tracks:
|
for otio_track in otio_timeline.audio_tracks():
|
||||||
if "Audio" not in otio_track.kind:
|
|
||||||
continue
|
|
||||||
self.log.debug("_" * 50)
|
self.log.debug("_" * 50)
|
||||||
playhead = 0
|
playhead = 0
|
||||||
for otio_clip in otio_track:
|
for otio_clip in otio_track:
|
||||||
|
|
@ -173,19 +168,22 @@ class ExtractOtioAudioTracks(pyblish.api.ContextPlugin):
|
||||||
if isinstance(otio_clip, otio.schema.Gap):
|
if isinstance(otio_clip, otio.schema.Gap):
|
||||||
playhead += otio_clip.source_range.duration.value
|
playhead += otio_clip.source_range.duration.value
|
||||||
elif isinstance(otio_clip, otio.schema.Clip):
|
elif isinstance(otio_clip, otio.schema.Clip):
|
||||||
start = otio_clip.source_range.start_time.value
|
media_av_start = otio_clip.available_range().start_time
|
||||||
duration = otio_clip.source_range.duration.value
|
clip_start = otio_clip.source_range.start_time
|
||||||
fps = otio_clip.source_range.start_time.rate
|
fps = clip_start.rate
|
||||||
|
conformed_av_start = media_av_start.rescaled_to(fps)
|
||||||
|
start = clip_start - conformed_av_start # ffmpeg ignores embedded tc
|
||||||
|
duration = otio_clip.source_range.duration
|
||||||
media_path = otio_clip.media_reference.target_url
|
media_path = otio_clip.media_reference.target_url
|
||||||
input = {
|
input = {
|
||||||
"mediaPath": media_path,
|
"mediaPath": media_path,
|
||||||
"delayFrame": playhead,
|
"delayFrame": playhead,
|
||||||
"startFrame": start,
|
"startFrame": start.to_frames(),
|
||||||
"durationFrame": duration,
|
"durationFrame": duration.to_frames(),
|
||||||
"delayMilSec": int(float(playhead / fps) * 1000),
|
"delayMilSec": int(float(playhead / fps) * 1000),
|
||||||
"startSec": float(start / fps),
|
"startSec": start.to_seconds(),
|
||||||
"durationSec": float(duration / fps),
|
"durationSec": duration.to_seconds(),
|
||||||
"fps": fps
|
"fps": float(fps)
|
||||||
}
|
}
|
||||||
if input not in output:
|
if input not in output:
|
||||||
output.append(input)
|
output.append(input)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue