bluesky-social / social-app

The Bluesky Social application for Web, iOS, and Android
https://bsky.app
MIT License
10.13k stars 1.29k forks source link

Add videos to link embed for third party platforms #5267

Open Tanza3D opened 1 month ago

Tanza3D commented 1 month ago

Is your feature request related to a problem? Please describe.

Linking posts with videos to other people on third party platforms e.g. Discord or Telegram does not show any video. image

Describe the solution you'd like

Should show the video video similar to this url using the app's built in video player; https://tanza.me/int/test2.html (visiting this in browser will never load, it only has meta tags) image image

apologies if this is already reported or fixed, i looked around PRs and issues and couldn't find anything

IsaacMarovitz commented 1 month ago

Okay, I've dug through how the player works and at least to my understanding, this isn't possible with how the CDN and video player is currently set up. The og:video:url meta tags will only work with a proper continuous mp4, but Bluesky splits videos into several MPEG TS files, and then plays them back using a m3u8 playlist manifest.

In the case of this example video I've been testing with, there is an initial parent manifest with multiple resolutions available

Screenshot 2024-09-14 at 13 18 37

Then a following manifest with each portion of the video

Screenshot 2024-09-14 at 13 18 24

TLDR; I don't think this is compatible with Open Graph in it's current state unless there is a full video stored somewhere else on the CDN I don't know about.

IsaacMarovitz commented 1 month ago

Okay well it turns out the original is stored somewhere and can be found using this. Not sure how to get this through the official API yet.

MetaflameDragon commented 1 month ago

The original video is stored in full on each PDS, you can find it by getting a user's PDS (this will most likely be a Bluesky PDS from "the mycosphere", but there are a few self-hosted ones too now). In fact, PDSes store the video in 1080p 3kbps, while the CDN serves it in only up to 720p (for now).

That's how cbsky.app does it, it just links to the raw blob directly. However, I'm not sure if that's the intended way that Bluesky would want to do it - it would fail to load the video if the PDS goes offline (while the video might remain cached on the CDN, same as how AppViews keep posts visible even when a PDS is offline). Image post embeds link to the CDN, so it would probably need more discussion to see if linking to the video blobs directly is fine.

I've been looking into patching the feature in yesterday, first trying to get it working locally.

MetaflameDragon commented 1 month ago

To add: the format to retrieve the video blob is:

<PDS domain>/xrpc/com.atproto.sync.getBlob?did=<DID>&cid=<Video blob CID>

So, for example:

https://bsky.app/profile/pfrazee.com/post/3l3vrskfzqu2s

https://morel.us-east.host.bsky.network/xrpc/com.atproto.sync.getBlob?did=did:plc:ragtjsm2j2vknwkz3zp4oxrd&cid=bafkreif3dm4pfrneqtvnvsy743qfne6uxrfa6w24zevmnv6vvqnhstvg4m

The video CID is returned in the embed field of a post (e.g. via app.bsky.feed.getPostThread).

Also, while the playlist isn't useful for us, the CDN-provided thumbnail is still usable, as it's a simple jpg. (This one is included directly in the embed field too.)

icehaku commented 1 month ago

If the video player is too complex for the moment, we could at least get that JPG thumb as a solution for now. Its quite boring to share a bluesky link video, and it only shows the text part of it: https://bsky.app/profile/aisse.bsky.social/post/3l4gscjim6o25 image