27

I'm trying to overlay some text emoticons on top of a video using ffmpeg.. This works fine for normal TTF's e.g.

ffmpeg -i video.mp4 -vf drawtext="Arial.ttf: text='YENTL 😎 Bresseleers ': fontcolor=white: fontsize=24: x=(w-text_w)/2: y=(h-text_h-line_h)/2" -codec:a copy output.mp4 -y

I can use the OpenSansEmoji font which gets me closer to what I need..

ffmpeg -i video.mp4 -vf drawtext="OpenSansEmoji.ttf.ttf: text='YENTL 😎 Bresseleers ': fontcolor=white: fontsize=24: x=(w-text_w)/2: y=(h-text_h-line_h)/2" -codec:a copy output.mp4 -y`

However when I try with a TTF file with coloured emoji's like emojione or Noto Color Emoji I get the below error:

[Parsed_drawtext_0 @ 0x7fd643700000] Could not set font size to 24 pixels: invalid module handle
[AVFilterGraph @ 0x7fd643608b80] Error initializing filter 'drawtext' with args 'fontfile=AppleColorEmoji.ttf: text=YENTL 😎 Bresseleers : fontcolor=white: fontsize=24: x=(w-text_w)/2: y=(h-text_h-line_h)/2'
Error opening filters!`

Any ideas?

6
  • At present (Jan-2016), regular font drawing engines do not support "colored characters" - there even isn't a definitive standard yet! All current implementations use private data in their fonts. That's why any ol' font with 'regular' characters (i.e., an outline that gets filled with one (1) color) work but proprietary format bitmaps and outlines do not. Commented Jan 20, 2016 at 22:35
  • 2
    I was looking into this a bit further - it looks like libfreetype (the library which ffmpeg used to render text) has support for colored fonts since v2.5 - ref lists.gnu.org/archive/html/freetype-announce/2013-06/… & freetype.org/freetype2/docs/reference/… do you know what version ffmpeg uses and if it can be upgraded? Commented Jan 21, 2016 at 16:48
  • Doesn't work with ffmpeg compiled with libfreetype 2.6.2 Commented Jan 21, 2016 at 17:59
  • Any update on this? Commented Jan 1, 2018 at 6:23
  • Try surrounding the text in single quotes and eliminate unnecessary spaces in the command. Commented Oct 29, 2019 at 23:21

2 Answers 2

2

For a dirty workaround one can manually adjust the emoji on top of a character like so

ffmpeg -i video.mp4 -i "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/apple/237/smiling-face-with-sunglasses_1f60e.png" -filter_complex "[1:v]scale=24:24,format=argb,colorchannelmixer=aa=0.5[ovrl],[0:v]drawtext=text='YENTL O Bresseleers':fontcolor=white:fontsize=24:x='(w-text_w)/2':y='(h-text_h-line_h)/2'[text],[text][ovrl]overlay=main_w/2-46:main_h/2-20" -codec:a copy output.mp4 -y

and then remove the ,format=argb,colorchannelmixer=aa=0.5 part when the position is correct.

Sign up to request clarification or add additional context in comments.

Comments

1

Currently, FFMPEG doesn't support emojis and some special characters, i had the same issue, and to solve that i took a different approach, you can follow the same steps.

  1. After adding your text, when you want to save it..
  2. Convert those texts into the image
  3. Add those images to FFMPEG with the help of the "Image overlay command".

i hope these steps help.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.