Last active
January 29, 2024 16:38
-
-
Save markizano/a0a70eb220905d35deac05e8b17430c1 to your computer and use it in GitHub Desktop.
Test a font for being able to render an emoji using ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Tests out the generation of subtitles using a smiley emoji and the "sparkles" emoji. | |
# Note that some fonts like sans and sans-serif may have the smiley (0xf09f9884), but not the sparkles (0xe29ca8). | |
# Some fonts will have neither. | |
# I think support for emojis in FFMPEG/mpv/fonts could use some improvement. | |
exec 4>subs.srt | |
echo "1" >&4 | |
echo "00:00:00.000 --> 00:00:02.000" >&4 | |
echo -e "Now let's see that \xf0\x9f\x98\x84 !!!" >&4 | |
echo -e "\n" >&4 | |
echo "00:00:02.000 --> 00:00:04.000" >&4 | |
echo -e "How about \xe2\x9c\xa8sparkles\xe2\x9c\xa8 ??" >&4 | |
echo -e "\n" >&4 | |
exec 4>&- | |
font="${1:-sans-serif}" | |
filter_complex="[0:v]subtitles=subs.srt:force_style='Alignment=0,PrimaryColour=&H00FFFFFF" | |
filter_complex+=",FontName=${font},OutlineColour=&H40000000,BorderStyle=3,Fontsize=25,MarginV=25'" | |
filter_complex+=",format=yuv420p[v]" | |
lavfi="color=0x00000000:size=512x512,fps=25,format=rgba,setsar=1:1" | |
ffmpeg -hide_banner -v debug -f lavfi -t 4 -i "$lavfi" -i subs.srt \ | |
-filter_complex "$filter_complex" -map [v] -y subs.mp4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment