Skip to content

Commit

Permalink
Use existing File object data when creating Clip objects... instead o…
Browse files Browse the repository at this point in the history
…f a new Clip object reader.
  • Loading branch information
jonoomph committed Feb 10, 2023
1 parent c126b83 commit 419aa10
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
12 changes: 1 addition & 11 deletions src/windows/add_to_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,13 @@ def accept(self):
new_clip["layer"] = track_num
new_clip["file_id"] = file.id
new_clip["title"] = filename
new_clip["reader"] = file.data

# Skip any clips that are missing a 'reader' attribute
# TODO: Determine why this even happens, as it shouldn't be possible
if not new_clip.get("reader"):
continue # Skip to next file

# Overwrite frame rate (incase the user changed it in the File Properties)
file_properties_fps = float(file.data["fps"]["num"]) / float(file.data["fps"]["den"])
file_fps = float(new_clip["reader"]["fps"]["num"]) / float(new_clip["reader"]["fps"]["den"])
fps_diff = file_fps / file_properties_fps
new_clip["reader"]["fps"]["num"] = file.data["fps"]["num"]
new_clip["reader"]["fps"]["den"] = file.data["fps"]["den"]
# Scale duration / length / and end properties
new_clip["reader"]["duration"] *= fps_diff
new_clip["end"] *= fps_diff
new_clip["duration"] *= fps_diff

# Check for optional start and end attributes
start_time = 0
end_time = new_clip["reader"]["duration"]
Expand Down
12 changes: 1 addition & 11 deletions src/windows/views/webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -2984,6 +2984,7 @@ def callback(self, data, callback_data):
new_clip = json.loads(c.Json())
new_clip["file_id"] = file.id
new_clip["title"] = filename
new_clip["reader"] = file.data

# Skip any clips that are missing a 'reader' attribute
if not new_clip.get("reader"):
Expand All @@ -3004,17 +3005,6 @@ def callback(self, data, callback_data):
if file.data["media_type"] == "image":
new_clip["end"] = get_app().get_settings().get("default-image-length") # default to 8 seconds

# Overwrite frame rate (incase the user changed it in the File Properties)
file_properties_fps = float(file.data["fps"]["num"]) / float(file.data["fps"]["den"])
file_fps = float(new_clip["reader"]["fps"]["num"]) / float(new_clip["reader"]["fps"]["den"])
fps_diff = file_fps / file_properties_fps
new_clip["reader"]["fps"]["num"] = file.data["fps"]["num"]
new_clip["reader"]["fps"]["den"] = file.data["fps"]["den"]
# Scale duration / length / and end properties
new_clip["reader"]["duration"] *= fps_diff
new_clip["end"] *= fps_diff
new_clip["duration"] *= fps_diff

# Add clip to timeline
self.update_clip_data(new_clip, only_basic_props=False, transaction_id=tid)

Expand Down

0 comments on commit 419aa10

Please sign in to comment.