0

I am using Moviepy to write text on videoclip. Without method=pango it gives proper results enter image description here

But when I use method=pango it does not show the text and shows some unrecognizable characters enter image description here

My textclip without pango looks like this:

(
TextClip(text_line.strip().upper(), font="URW-Bookman-Demi", fontsize=100, color='yellow')
                    .set_position(('center', 'center'))
                    .set_duration(end-start)
                    .set_start(start)
                   )
)

My textclip with pango looks like this:

(
TextClip(f'{text_line}<span foreground="#FF4567" background="black"><tt>{key}</tt></span>', 
           font="DejaVu Mono Sans", fontsize=100, color='yellow', method="pango")
           .set_position(('center', 'center'))
           .set_duration(end-start)
           .set_start(start)
)

I want to have only a particular word colored, {key} contains that word and {text_line} is remaining sentence.

I'm running this in colab. Am I missing some dependencies? I'm installing following:

!apt update
!apt install -y libpango-1.0-0
!apt install -y libsdl-pango-dev
!apt install python3-gi python3-gi-cairo gir1.2-gtk-4.0
!apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-4.0
!apt install imagemagick
!apt install ffmpeg
!pip3 install moviepy
!sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml
!pip install imageio
!pip install --upgrade imageio-ffmpeg
!pip install pycairo
!pip install PyGObject

Or is it the font? Or something else?

Yadnesh Salvi
  • 175
  • 1
  • 18
  • Changed the font to 'Arial' and it worked. Now need to find which fonts are supported, if anyone can help with that it would be great. – Yadnesh Salvi May 18 '23 at 06:36
  • looks like unicode text problem. if reading text from file pass encoding parameter encoding="utf8" – geekonweb Jul 27 '23 at 07:17

0 Answers0