Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding emoji with moviepy #507

Closed
justswim opened this issue Mar 22, 2017 · 10 comments
Closed

Adding emoji with moviepy #507

justswim opened this issue Mar 22, 2017 · 10 comments
Labels
text Issues dealing with TextClip, SubtitlesClip, or handling of text in general.

Comments

@justswim
Copy link
Contributor

Hi,

I was wondering if it was possible to add emoji characters with TextClip. For example, rendering something like this: 😅😂😂😂 on top of a video.

I tried adding a text clip with the proper unicode characters, but they show up as question marks.

Thanks in advance for your help

@Zulko
Copy link
Owner

Zulko commented Mar 22, 2017

Not unless you use a specific emoji font. You can also load your emojis as images using ImageClip.

@Zulko Zulko closed this as completed Mar 22, 2017
@Yash17Agrawal
Copy link

@Zulko @justswim can you list the font type for emoji because all the available solutions suggest converting to bytes and then using it. I don't want to use ImageClip for now. So can you please suggest the font type.

@justswim
Copy link
Contributor Author

I was never actually able to get this to work. I think there is an underlying issue with ffmpeg which prevents emojis from being supported.

@notanotherbrick
Copy link

Wondering if this worked for anyone now?

@makiisthenes
Copy link

Anyone found a solution to this? or is it a problem forever to be forgotten and lost :(((

@mrhosein
Copy link

mrhosein commented Apr 19, 2021

MS Word displays emojis with font 'Segoe-UI-Emoji'. When I set the font of my clip to this, it was able to display the emoji's but not with colours.

For example:
txt = TextClip(temp_comment, font = 'Segoe-UI-Emoji', fontsize = 44)

@makiisthenes
Copy link

MS Word displays emojis with font 'Segoe-UI-Emoji'. When I set the font of my clip to this, it was able to display the emoji's but not with colours.

For example:

txt = TextClip(temp_comment, font = 'Segoe-UI-Emoji', fontsize = 44)

Thanks for this!

@kaka1909
Copy link

kaka1909 commented Aug 12, 2023

For those who are still finding solutions to add colorful emoji to video, here is a demo.

The prequistes:

  1. install Pilmoji: pip install -U pilmoji
  2. download a colorful emoji font, like Noto Color Emoji

The solution:

  1. Draw an image based on emoji and emoji font.
  2. Make an image clip

The code to mix-in an emoji to a video:

    def make_emoji_image(emoji, font_path, font_size):
        emoji_font = ImageFont.truetype(font_path, font_size)
        text_size = emoji_font.getsize(emoji.strip())
        image = Image.new("RGBA", text_size, (0, 0, 0, 0))
        with Pilmoji(image) as pilmoji:
            pilmoji.text((0, 0), emoji.strip(), (0, 0, 0), emoji_font)
        return np.array(image)
    
    video_clip = VideoFileClip("/path/to/your/video")
    emoji_clip = ImageClip(make_emoji_image("😜", "/path/to/your/emoji/font", 48), duration=10).set_start(0)
    result = CompositeVideoClip([video_clip, emoji_clip])
    result.write_videofile("/path/to/output")

@tyler239
Copy link

tyler239 commented Feb 2, 2024

The solution of @kaka1909 works fine, but not for apple emojis :( . I tried to just use the apple emoji font from https://github.com/samuelngs/apple-emoji-linux but it did not work. It raises an "OSError: invalid pixel size". Anyone trying to work with apple emojis ?

@keikoro keikoro added the text Issues dealing with TextClip, SubtitlesClip, or handling of text in general. label Feb 10, 2024
@benjamenharper
Copy link

For those who are still finding solutions to add colorful emoji to video, here is a demo.

The prequistes:

  1. install Pilmoji: pip install -U pilmoji
  2. download a colorful emoji font, like Noto Color Emoji

The solution:

  1. Draw an image based on emoji and emoji font.
  2. Make an image clip

The code to mix-in an emoji to a video:

    def make_emoji_image(emoji, font_path, font_size):
        emoji_font = ImageFont.truetype(font_path, font_size)
        text_size = emoji_font.getsize(emoji.strip())
        image = Image.new("RGBA", text_size, (0, 0, 0, 0))
        with Pilmoji(image) as pilmoji:
            pilmoji.text((0, 0), emoji.strip(), (0, 0, 0), emoji_font)
        return np.array(image)
    
    video_clip = VideoFileClip("/path/to/your/video")
    emoji_clip = ImageClip(make_emoji_image("😜", "/path/to/your/emoji/font", 48), duration=10).set_start(0)
    result = CompositeVideoClip([video_clip, emoji_clip])
    result.write_videofile("/path/to/output")

this worked.. was ready to jump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
text Issues dealing with TextClip, SubtitlesClip, or handling of text in general.
Projects
None yet
Development

No branches or pull requests

10 participants