Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.42k stars 1.55k forks source link

Possibility to outline text (not stroke)? #2001

Open nonrice opened 1 year ago

nonrice commented 1 year ago

I would like to give my subtitles an outline that only exist on the outside of the characters. The only fix mentioned #1318 suggests writing 2 copies of the text, one stroked, one unstroked. However, because the stroked text is wider, it changes the line wrapping, causing the two sets of text to be mismatched some of the time. How can I achieve outlined subtitles with proper line wrapping?

Devanaath commented 1 year ago

I am not sure whether there is an alternative for text stroke. But if your aim is to differentiate the text from the background, You got 2 options(based on my knowing):

  1. you can set Parameter bg_color in the Textclip to set a background color.
  2. you can use on_color) to set background for the text. Here you can also set opacity of the text background color.
nonrice commented 1 year ago

Actually I ended up figuring out a workaround. I ended up choosing the ImageMagick "Label" style, and performing text wrapping with the builtin textwrap library, solving my problems with the text wrap breaking. Not a complete fix, since you have to be mindful when choosing the number of characters to wrap at, but it works for my purpose. Really hoping an easier way to do this could be implemented, since this is such a common task, especially in modern videos.

TheHimanshuRastogi commented 1 year ago

@nonrice If you're using a TextClip there are 2 additional parameters for stroke, stroke_color: str and stroke_width: int and to use Text Wrap use method='caption'.

nonrice commented 1 year ago

@TheHimanshuRastogi This creates a middle stroke, not an outer stroke. This is not what I am looking for.

TheHimanshuRastogi commented 1 year ago

@nonrice Hope you found your solution ASAP.