Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offset is no longer implicitly multiplied by clip speed #458

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auto_editor/formats/fcp11.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def make_clip(ref: str, clip: TlVideo | TlAudio, speed_warn: bool) -> bool:
"ref": ref,
"offset": fraction(clip.start),
"duration": fraction(clip.dur),
"start": fraction(int(clip.offset // clip.speed)),
"start": fraction(clip.offset),
"tcFormat": "NDF",
}
asset = SubElement(spine, "asset-clip", clip_properties)
Expand Down
12 changes: 6 additions & 6 deletions auto_editor/formats/fcp7.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def xml_bool(val: str) -> bool:

start = clipitem["start"]
dur = clipitem["end"] - start
offset = int(clipitem["in"] * speed)
offset = clipitem["in"]

vobjs[t].append(
TlVideo(start, dur, sources[file_id], offset, speed, stream=0)
Expand Down Expand Up @@ -324,7 +324,7 @@ def xml_bool(val: str) -> bool:

start = clipitem["start"]
dur = clipitem["end"] - start
offset = int(clipitem["in"] * speed)
offset = clipitem["in"]

aobjs[t].append(
TlAudio(
Expand Down Expand Up @@ -414,8 +414,8 @@ def fcp7_write_xml(name: str, output: str, tl: v3, log: Log) -> None:

_start = f"{clip.start}"
_end = f"{clip.start + clip.dur}"
_in = f"{int(clip.offset / clip.speed)}"
_out = f"{int(clip.offset / clip.speed) + clip.dur}"
_in = f"{clip.offset}"
_out = f"{clip.offset + clip.dur}"

clipitem = ET.SubElement(track, "clipitem", id=f"clipitem-{j+1}")
ET.SubElement(clipitem, "name").text = src.path.stem
Expand Down Expand Up @@ -473,8 +473,8 @@ def fcp7_write_xml(name: str, output: str, tl: v3, log: Log) -> None:

_start = f"{aclip.start}"
_end = f"{aclip.start + aclip.dur}"
_in = f"{int(aclip.offset / aclip.speed)}"
_out = f"{int(aclip.offset / aclip.speed) + aclip.dur}"
_in = f"{aclip.offset}"
_out = f"{aclip.offset + aclip.dur}"

if not src.videos:
clip_item_num = j + 1
Expand Down
6 changes: 3 additions & 3 deletions auto_editor/formats/shotcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def shotcut_write_mlt(output: str, tl: v3) -> None:

for clip in clips:
src = clip.src
length = to_timecode((clip.offset / clip.speed + clip.dur) / tb, "standard")
length = to_timecode((clip.offset + clip.dur) / tb, "standard")

if clip.speed == 1:
resource = f"{src.path}"
Expand Down Expand Up @@ -127,8 +127,8 @@ def shotcut_write_mlt(output: str, tl: v3) -> None:

producers = 0
for i, clip in enumerate(clips):
_in = to_timecode(clip.offset / clip.speed / tb, "standard")
_out = to_timecode((clip.offset / clip.speed + clip.dur) / tb, "standard")
_in = to_timecode(clip.offset / tb, "standard")
_out = to_timecode((clip.offset + clip.dur) / tb, "standard")

tag_name = f"chain{i}"
if clip.speed != 1:
Expand Down
4 changes: 2 additions & 2 deletions auto_editor/make_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def clipify(chunks: Chunks, src: FileInfo, start: int = 0) -> list[Clip]:
if dur == 0:
continue

offset = chunk[0]
offset = int(chunk[0] / chunk[2])

if not (clips and clips[-1].start == round(start)):
clips.append(Clip(start, dur, offset, chunk[2], src))
Expand Down Expand Up @@ -228,7 +228,7 @@ def echunk(
if dur == 0:
continue

offset = chunk[1]
offset = int(chunk[1] / chunk[3])

if not (clips and clips[-1].start == round(start)):
clips.append(Clip(start, dur, offset, chunk[3], chunk[0]))
Expand Down
3 changes: 2 additions & 1 deletion auto_editor/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ def all_cuts(tl: v3, in_len: int) -> list[int]:
oe: list[tuple[int, int]] = []

for clip in tl.a[0]:
oe.append((clip.offset, clip.offset + clip.dur))
old_offset = clip.offset * clip.speed
oe.append((round(old_offset * clip.speed), round(old_offset + clip.dur)))

cut_lens = []
i = 0
Expand Down
4 changes: 2 additions & 2 deletions auto_editor/render/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ def make_new_audio(
del leng

samp_list = samples[(clip.src, clip.stream)]
samp_start = clip.offset * sr // tb
samp_end = round((clip.offset + clip.dur * clip.speed) * sr / tb)
samp_start = round(clip.offset * clip.speed * sr / tb)
samp_end = round((clip.offset + clip.dur) * clip.speed * sr / tb)
if samp_end > len(samp_list):
samp_end = len(samp_list)

Expand Down
2 changes: 1 addition & 1 deletion auto_editor/render/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def render_av(
for lobj in layer:
if isinstance(lobj, TlVideo):
if index >= lobj.start and index < (lobj.start + lobj.dur):
_i = lobj.offset + round((index - lobj.start) * lobj.speed)
_i = round((lobj.offset + index - lobj.start) * lobj.speed)
obj_list.append(VideoFrame(_i, lobj.src))
elif index >= lobj.start and index < lobj.start + lobj.dur:
obj_list.append(lobj)
Expand Down