Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ffmpeg with drawtext and a emoji TTF

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?

like image 236
morrislaptop Avatar asked Jan 19 '16 15:01

morrislaptop


1 Answers

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.

like image 163
ovikoomikko Avatar answered Oct 24 '22 05:10

ovikoomikko