1

I have a program which allows users to create gifs from youtube videos using yt-dlp and ffmpeg. Unfortunately, ffmpeg does not support color emojis.

Here's what it looks like when you try:

ffmpeg -ss 1:57 -to 2:00 -copyts -i /tmp/ytgif_cache/video_httpswwwyoutubecomwatchvnrqxmQruto.webm -filter_complex '[0:v] fps=10, scale=640:-1, split [a][b], [a] palettegen [p], [b][p] paletteuse, drawtext=borderw=1:bordercolor=black:fontcolor=white:fontsize=30:x=(w-text_w)/2:y=(h-text_h)-10:text=🔥 flames 🔥' flames.gif

"flames" with two tofu emoji

Imagemagick

Imagemagick, as compiled for my by homebrew, does no better on a static image:

convert -background lightblue -fill blue -pointsize 72 "label:Hot 🌶 stuff" png:- | imgcat

gives:

"hot stuff" with a tofu for the emoji

(Possibly re-compiling with pango would fix this? But my users are not likely to want to have to install custom versions of imagemagick)

Looking for suggestions

What are my other options? How can I render a text string containing emojis into an image suitable for a video caption in a reasonably cross-platform manner?

1 Answer 1

1

ImageMagick does support some emojis at the very least. You have to change the coder though. An example with pango coder:

magick -background lightblue -fill blue -pointsize 72 "pango:Hot 🔥 stuff
" test.png

Output:

Text output

I had no luck with the pepper (🌶) one though, on Windows latest version. Not entirely sure why, as its Unicode neighbors (🌵) and (🌷) did work fine. Perhaps a font issue. Or Unicode 7+ characters aren't supported too well within the not too up-to-date Pango version included with ImageMagick.

Could have better chances on Linux, where Pango is coming from. Don't have time to further mess with that, personally.

3
  • I'm on mac, where homebrew unfortunately doesn't ship pango compiled in with imagemagick. I also should have specified that I'd like to have color emoji support! Will edit the question.
    – llimllib
    Jul 14, 2023 at 20:23
  • Your question is wrong in that case, as it asks for cross-platform solution, not a Mac solution specifically. There are some potential solutions for Pango on Mac BTW stackoverflow.com/questions/25838714/… east.fm/posts/imagemagick-pango/index.html
    – Destroy666
    Jul 15, 2023 at 10:36
  • I'm on a mac but I am indeed looking for a cross-platform solution
    – llimllib
    Jul 18, 2023 at 13:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.