Skip to content

Commit

Permalink
Protecting timeline args from non-Integer values. Detected on Sentry:…
Browse files Browse the repository at this point in the history
… OPENSHOT-245G
  • Loading branch information
jonoomph committed Apr 13, 2023
1 parent ebe2ad3 commit a284f22
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/classes/timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def __init__(self, window):
channel_layout = project.get("channel_layout")

# Create an instance of a libopenshot Timeline object
self.timeline = openshot.Timeline(width, height, openshot.Fraction(fps["num"], fps["den"]), sample_rate, channels,
channel_layout)
self.timeline = openshot.Timeline(width, height, openshot.Fraction(fps["num"], fps["den"]),
sample_rate, channels, channel_layout)
self.timeline.info.channel_layout = channel_layout
self.timeline.info.has_audio = True
self.timeline.info.has_video = True
Expand Down
2 changes: 1 addition & 1 deletion src/windows/cutting.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __init__(self, file=None, preview=False):
self.fps = float(self.fps_num) / float(self.fps_den)
self.width = int(file.data['width'])
self.height = int(file.data['height'])
self.sample_rate = get_app().project.get("sample_rate")
self.sample_rate = int(get_app().project.get("sample_rate"))
self.channels = int(file.data['channels'])
self.channel_layout = int(file.data['channel_layout'])

Expand Down
10 changes: 5 additions & 5 deletions src/windows/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ def __init__(self, *args, **kwargs):
project_timeline.ClearAllCache()

# Get the original timeline settings
width = project_timeline.info.width
height = project_timeline.info.height
width = int(project_timeline.info.width)
height = int(project_timeline.info.height)
fps = project_timeline.info.fps
sample_rate = project_timeline.info.sample_rate
channels = project_timeline.info.channels
channel_layout = project_timeline.info.channel_layout
sample_rate = int(project_timeline.info.sample_rate)
channels = int(project_timeline.info.channels)
channel_layout = int(project_timeline.info.channel_layout)

# Create new "export" openshot.Timeline object
self.timeline = openshot.Timeline(
Expand Down
14 changes: 8 additions & 6 deletions src/windows/preview_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,16 @@ def LoadFile(self, path=None):

# Get some settings from the project
fps = project.get("fps")
width = project.get("width")
height = project.get("height")
sample_rate = project.get("sample_rate")
channels = project.get("channels")
channel_layout = project.get("channel_layout")
width = int(project.get("width"))
height = int(project.get("height"))
sample_rate = int(project.get("sample_rate"))
channels = int(project.get("channels"))
channel_layout = int(project.get("channel_layout"))

# Create an instance of a libopenshot Timeline object
self.clip_reader = openshot.Timeline(width, height, openshot.Fraction(fps["num"], fps["den"]), sample_rate, channels, channel_layout)
self.clip_reader = openshot.Timeline(width, height,
openshot.Fraction(fps["num"], fps["den"]),
sample_rate, channels, channel_layout)
self.clip_reader.info.channel_layout = channel_layout
self.clip_reader.info.has_audio = True
self.clip_reader.info.has_video = True
Expand Down
22 changes: 12 additions & 10 deletions src/windows/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def __init__(self, file=None, clip=None):
self.file_path = file.absolute_path()

c_info = clip.Reader().info
self.fps = c_info.fps.ToInt() #float(self.fps_num) / float(self.fps_den)
self.fps_num = self.fps #int(file.data['fps']['num'])
self.fps_den = 1 #int(file.data['fps']['den'])
self.width = c_info.width #int(file.data['width'])
self.height = c_info.height #int(file.data['height'])
self.sample_rate = c_info.sample_rate #int(file.data['sample_rate'])
self.channels = c_info.channels #int(file.data['channels'])
self.channel_layout = c_info.channel_layout #int(file.data['channel_layout'])
self.video_length = int(self.clip.Duration() * self.fps) + 1 #int(file.data['video_length'])
self.fps = c_info.fps.ToInt()
self.fps_num = c_info.fps.num
self.fps_den = c_info.fps.den
self.width = c_info.width
self.height = c_info.height
self.sample_rate = int(c_info.sample_rate)
self.channels = int(c_info.channels)
self.channel_layout = int(c_info.channel_layout)
self.video_length = int(self.clip.Duration() * self.fps) + 1

# Apply effects to region frames
for effect in clip.Effects():
Expand All @@ -125,7 +125,9 @@ def __init__(self, file=None, clip=None):
self.viewport_rect = self.videoPreview.centeredViewport(self.width, self.height)

# Create an instance of a libopenshot Timeline object
self.r = openshot.Timeline(self.viewport_rect.width(), self.viewport_rect.height(), openshot.Fraction(self.fps_num, self.fps_den), self.sample_rate, self.channels, self.channel_layout)
self.r = openshot.Timeline(self.viewport_rect.width(), self.viewport_rect.height(),
openshot.Fraction(self.fps_num, self.fps_den),
self.sample_rate, self.channels, self.channel_layout)
self.r.info.channel_layout = self.channel_layout
self.r.SetMaxSize(self.viewport_rect.width(), self.viewport_rect.height())

Expand Down

0 comments on commit a284f22

Please sign in to comment.