diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index fd43a81a2..d8a3a96f5 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -1438,6 +1438,11 @@ class TextClip(ImageClip): duration Duration of the clip + + bg_radius + A paramater to round the edges of the text background. Defaults to 0 if there + is no background. It will have no effect if there is no bg_colour added. + The higher the value, the more rounded the corners will become. """ @convert_path_to_string("filename") @@ -1460,6 +1465,7 @@ def __init__( interline=4, transparent=True, duration=None, + bg_radius=0, # TODO : Move this with other bg_param on next breaking release ): def break_text( width, text, font, font_size, stroke_width, align, spacing @@ -1719,9 +1725,20 @@ def find_optimum_font_size( if bg_color is None and transparent: bg_color = (0, 0, 0, 0) - img = Image.new(img_mode, (img_width, img_height), color=bg_color) - pil_font = ImageFont.truetype(font, font_size) - draw = ImageDraw.Draw(img) + if bg_radius is None: + bg_radius = 0 + + if bg_radius != 0: + img = Image.new(img_mode, (img_width, img_height), color=(0, 0, 0, 0)) + pil_font = ImageFont.truetype(font, font_size) + draw = ImageDraw.Draw(img) + draw.rounded_rectangle( + [0, 0, img_width, img_height], radius=bg_radius, fill=bg_color + ) + else: + img = Image.new(img_mode, (img_width, img_height), color=bg_color) + pil_font = ImageFont.truetype(font, font_size) + draw = ImageDraw.Draw(img) # Dont need allow break here, because we already breaked in caption text_width, text_height = find_text_size( diff --git a/moviepy/video/fx/Scroll.py b/moviepy/video/fx/Scroll.py index 1d469d112..d5c9d60a8 100644 --- a/moviepy/video/fx/Scroll.py +++ b/moviepy/video/fx/Scroll.py @@ -30,7 +30,6 @@ def __init__( y_start=0, apply_to="mask", ): - self.w = w self.h = h self.x_speed = x_speed diff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.py index b22aa2b6d..16700ee15 100644 --- a/moviepy/video/io/ffmpeg_reader.py +++ b/moviepy/video/io/ffmpeg_reader.py @@ -459,12 +459,12 @@ def parse(self): # for default streams, set their numbers globally, so it's # easy to get without iterating all if self._current_stream["default"]: - self.result[f"default_{stream_type_lower}_input_number"] = ( - input_number - ) - self.result[f"default_{stream_type_lower}_stream_number"] = ( - stream_number - ) + self.result[ + f"default_{stream_type_lower}_input_number" + ] = input_number + self.result[ + f"default_{stream_type_lower}_stream_number" + ] = stream_number # exit chapter if self._current_chapter: