DEV Community

Cover image for Video encoded as emojis⁉️ Stored in a DB? 😱🤯

Video encoded as emojis⁉️ Stored in a DB? 😱🤯

GrahamTheDev on April 23, 2024

OK, even I think I have gone too far this time! Can we convert video to emojis (silly) and then save those emojis in a DB (a row per line of "pixe...
Collapse
 
mattlewandowski93 profile image
Matt Lewandowski

This is great haha. I can't help but want to increase the performance even more.

Have you considered returning more than 1 frame of data from the API at a time? If the size isn't that big, you could request 60 frames at a time and you might get a smooth playback. Might have to also update your postgres fn though.

Also curious if you played around with different table formats and query performance. aggregating json objects can be pretty slow, but adding an index plus a third column for each individual px on the row might be faster!

Would love to see a 30fps version of this 😆

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

It is deliberately one frame at a time to test out Supabase latency.

The function is already written for all frames 😁

I changed the article and added a section to explain why I did it this was as it is a great point! 🙏🏼💗

create or replace function get_all_frames () 
RETURNS table(frametext text)
LANGUAGE plpgsql 
as $$
BEGIN
  --grab current board
   RETURN QUERY SELECT STRING_AGG("rowdata", CHR(13)) AS frame
FROM video2
GROUP BY frameid
ORDER BY frameid ASC;
end; 
$$;
Enter fullscreen mode Exit fullscreen mode
Collapse
 
mattlewandowski93 profile image
Matt Lewandowski

Ah I see! seems to be the latency killing it here in Australia then. Getting about 1 second of latency per request.

Thread Thread
 
grahamthedev profile image
GrahamTheDev

Ahhhh, yeah, the server is US I chose.

Another optimisation we could do there, save the data as a file and serve it from a CDN.

Sorry it isn't as fun for you, it is only 90ms here in the UK so I didn't consider how much worse it could be there.

Hopefully the video shows you what it should look like 🥲

Collapse
 
link2twenty profile image
Andrew Bone • Edited

I'm surprised you didn't use line-height and letter-spacing to reduce the gaps 😲

Collapse
 
grahamthedev profile image
GrahamTheDev

Oh I did try that actually, but it lost the “charm” of being individual emojis.

Plus you get some strange lines due to it being such a small font size. 😢💗

Collapse
 
raibtoffoletto profile image
Raí B. Toffoletto

I can't believe it plays out!! I was expecting a stop motion movie, but the framerate is actually not bad! Here it goes my next vacation week trying to reproduce this 😂

Collapse
 
grahamthedev profile image
GrahamTheDev

Yeah it is decent framerate on Wifi with a decent connection. But someone did point out that they were in Australia and the round trip time meant they saw 1FPS! Also sucks on 3G/4G! haha.

If you do reproduce it (and make it better!) send me a link, would love to see it! 💗

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

I've been Rick rolled 😮

Collapse
 
grahamthedev profile image
GrahamTheDev

Remoji rolled! 🤷🤣💗

Collapse
 
grahamthedev profile image
GrahamTheDev

And people wonder why nobody ever asks me to write for them!

Do me a favour, tweet at Supabase if you enjoyed this article, that way they might actually ask me to write for them again! 🤷🏼‍♂️🤣💗

Collapse
 
devarshishimpi profile image
Devarshi Shimpi

This is an amazing blog, Graham!

Collapse
 
grahamthedev profile image
GrahamTheDev

🙏💗

Collapse
 
shricodev profile image
Shrijal Acharya

The idea itself is insane. Amazing work!

Collapse
 
grahamthedev profile image
GrahamTheDev

Haha pretty much sums up this whole series! Glad you liked it though. 💗

Collapse
 
akshay09 profile image
worklikeakshay@gmail.com

Great project tbh !

Collapse
 
joao9aulo profile image
João Paulo Martins Silva

That is the way to learn, doing crazy things, congrats!