Skip to content

Instantly share code, notes, and snippets.

@Clybius
Last active May 9, 2024 14:51
Show Gist options
  • Save Clybius/103bdf0ebde254c348e38f023191f494 to your computer and use it in GitHub Desktop.
Save Clybius/103bdf0ebde254c348e38f023191f494 to your computer and use it in GitHub Desktop.
Embed AV1/No File Size Capped Videos in Discord
<head>
<meta property="og:image" content="GifToEmbedURL"> # Change the content to the link of a gif of your choice, which will be shown as the embed.
<meta property="og:type" content="video.other">
<meta property="og:video:url" content="VideoToEmbedURL"> # Change the content to the link of a video of your choice. Will work with videos over 50 MB, and even unsupported codecs such as AV1!
<meta property="og:video:width" content="1920"> # Set this to the video's width and height, not required, but will show the video as intended if the aspect ratio and size is correct.
<meta property="og:video:height" content="1080">
</head>
@Clybius
Copy link
Author

Clybius commented Jun 23, 2022

Place this in a folder on your site, change a couple of things, and then paste the link.

Say you have a folder within public_html by the name of Morbius_4k
Place and modify the header contents of index.html within an index file of Morbius_4k, example modifications would be the gif and video change to a public link of Morbius in 4k.
Embed by chatting the URL of the folder!
How it should look to the end user

@Clybius
Copy link
Author

Clybius commented Jun 24, 2022

Do note that upon first viewing the embed, it may take a bit to load. If someone could provide input which provides context as to why this is happening, it will be much appreciated.

@ThatStella7922
Copy link

This is a feature of Discord, its embed system complies with OpenGraph web tags and is expected functionality. I use it on internal parts of my files site, files.thatstel.la.
The reason the embed takes a bit to load while first viewing is because Discordbot (the proxy that Discord uses to handle embeds identifies this way) has to cache the video to serve it to users.

Cool app though, makes uploading these a lot easier and I might make something myself for uploading using files.thatstel.la/upload, thanks for the inspiration

@Clybius
Copy link
Author

Clybius commented May 1, 2024

You are right that its expected behavior from OG tags, I'd consider only it unexpected in how Discord handles the files though. This is just essentially a way of working around the embed limit in Discord, which limits itself to H.264/VP9/WhateverElseOldCodec. It was originally intended to be a way to embed AV1 after I had noticed people doing this trick with gif/video swapping, but after further testing it worked on almost all file sizes and more codecs.


Also since this seems to be getting some attention, I'd recommend uploading to one's own file server (shoutout BuyVM & their slabs) instead of using a gracefully provided public service to do such. Especially for large H.264 clips which gamers love to record with, and love to not compress efficiently.

More importantly, maybe Discord could just fix this whole scenario by actually allowing AV1 embeds? And update their decoders?

@jhgg
Copy link

jhgg commented May 1, 2024

We will improve the situation. The code that deals with unfurling videos has a bit of tech debt and has not received much love. Additionally av1 support isn't ubiquitous just yet (with mobile clients right now not supporting it.)

However, the exploit here shouldn't need to exist since we should just do the right thing. Right now, we just give up under most circumstances if the video is too large, rather than looking at a subset of the video data to calculate enough metadata to render an embed. We have added this to the backlog and once resources free up we will look into improving this situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment