Skip to content

Commit 1e07ee3

Browse files
authored
Merge pull request #5202 from OpenShot/protect-timeline-args
Protecting timeline args from non-Integer values
2 parents db2e8e8 + a284f22 commit 1e07ee3

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

src/classes/timeline.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ def __init__(self, window):
5050
channel_layout = project.get("channel_layout")
5151

5252
# Create an instance of a libopenshot Timeline object
53-
self.timeline = openshot.Timeline(width, height, openshot.Fraction(fps["num"], fps["den"]), sample_rate, channels,
54-
channel_layout)
53+
self.timeline = openshot.Timeline(width, height, openshot.Fraction(fps["num"], fps["den"]),
54+
sample_rate, channels, channel_layout)
5555
self.timeline.info.channel_layout = channel_layout
5656
self.timeline.info.has_audio = True
5757
self.timeline.info.has_video = True

src/windows/cutting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __init__(self, file=None, preview=False):
9292
self.fps = float(self.fps_num) / float(self.fps_den)
9393
self.width = int(file.data['width'])
9494
self.height = int(file.data['height'])
95-
self.sample_rate = get_app().project.get("sample_rate")
95+
self.sample_rate = int(get_app().project.get("sample_rate"))
9696
self.channels = int(file.data['channels'])
9797
self.channel_layout = int(file.data['channel_layout'])
9898

src/windows/export.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ def __init__(self, *args, **kwargs):
110110
project_timeline.ClearAllCache()
111111

112112
# Get the original timeline settings
113-
width = project_timeline.info.width
114-
height = project_timeline.info.height
113+
width = int(project_timeline.info.width)
114+
height = int(project_timeline.info.height)
115115
fps = project_timeline.info.fps
116-
sample_rate = project_timeline.info.sample_rate
117-
channels = project_timeline.info.channels
118-
channel_layout = project_timeline.info.channel_layout
116+
sample_rate = int(project_timeline.info.sample_rate)
117+
channels = int(project_timeline.info.channels)
118+
channel_layout = int(project_timeline.info.channel_layout)
119119

120120
# Create new "export" openshot.Timeline object
121121
self.timeline = openshot.Timeline(

src/windows/preview_thread.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,16 @@ def LoadFile(self, path=None):
323323

324324
# Get some settings from the project
325325
fps = project.get("fps")
326-
width = project.get("width")
327-
height = project.get("height")
328-
sample_rate = project.get("sample_rate")
329-
channels = project.get("channels")
330-
channel_layout = project.get("channel_layout")
326+
width = int(project.get("width"))
327+
height = int(project.get("height"))
328+
sample_rate = int(project.get("sample_rate"))
329+
channels = int(project.get("channels"))
330+
channel_layout = int(project.get("channel_layout"))
331331

332332
# Create an instance of a libopenshot Timeline object
333-
self.clip_reader = openshot.Timeline(width, height, openshot.Fraction(fps["num"], fps["den"]), sample_rate, channels, channel_layout)
333+
self.clip_reader = openshot.Timeline(width, height,
334+
openshot.Fraction(fps["num"], fps["den"]),
335+
sample_rate, channels, channel_layout)
334336
self.clip_reader.info.channel_layout = channel_layout
335337
self.clip_reader.info.has_audio = True
336338
self.clip_reader.info.has_video = True

src/windows/region.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ def __init__(self, file=None, clip=None):
9494
self.file_path = file.absolute_path()
9595

9696
c_info = clip.Reader().info
97-
self.fps = c_info.fps.ToInt() #float(self.fps_num) / float(self.fps_den)
98-
self.fps_num = self.fps #int(file.data['fps']['num'])
99-
self.fps_den = 1 #int(file.data['fps']['den'])
100-
self.width = c_info.width #int(file.data['width'])
101-
self.height = c_info.height #int(file.data['height'])
102-
self.sample_rate = c_info.sample_rate #int(file.data['sample_rate'])
103-
self.channels = c_info.channels #int(file.data['channels'])
104-
self.channel_layout = c_info.channel_layout #int(file.data['channel_layout'])
105-
self.video_length = int(self.clip.Duration() * self.fps) + 1 #int(file.data['video_length'])
97+
self.fps = c_info.fps.ToInt()
98+
self.fps_num = c_info.fps.num
99+
self.fps_den = c_info.fps.den
100+
self.width = c_info.width
101+
self.height = c_info.height
102+
self.sample_rate = int(c_info.sample_rate)
103+
self.channels = int(c_info.channels)
104+
self.channel_layout = int(c_info.channel_layout)
105+
self.video_length = int(self.clip.Duration() * self.fps) + 1
106106

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

127127
# Create an instance of a libopenshot Timeline object
128-
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)
128+
self.r = openshot.Timeline(self.viewport_rect.width(), self.viewport_rect.height(),
129+
openshot.Fraction(self.fps_num, self.fps_den),
130+
self.sample_rate, self.channels, self.channel_layout)
129131
self.r.info.channel_layout = self.channel_layout
130132
self.r.SetMaxSize(self.viewport_rect.width(), self.viewport_rect.height())
131133

0 commit comments

Comments
 (0)