Rapougnac / VixBluesky

FixBluesky: Embed Bluesky links in Discord!
https://bskyx.app
GNU Affero General Public License v3.0
70 stars 3 forks source link

30 Second Limit? #13

Closed mobiusscarf closed 1 month ago

mobiusscarf commented 2 months ago

I'm just wondering if you could elaborate on the problems that led to the 30-seconds-or-less-only limit? I actually got it to work fine with a 34-second post yesterday, and I know Discord can embed longer videos because they do all the time for Twitter videos, and the BlueSky video limit is 60 seconds, which is half the Twitter limit

Could it at least post the first 30 seconds of the video along with the error?

Rapougnac commented 2 months ago

Well, technically it isn't Discord's fault, I know they can embed longer videos. Though, with Bluesky, they use the hls format, which needs to be converted into something readable by discord, and here lies the problem, other services like vxtwitter, ddinstagram etc just get the video link and that's all. For blueksks, remuxing the video takes time, and discord only fetches the video for approximately ~5 seconds before timing out, if the full video hasn't been sent in this time window, no embed is displayed at all. I guess 35s videos work because they are available within 5s, whereas longer video does not.

mobiusscarf commented 2 months ago

Forgive my ignorance, but do the .ts files need to be remuxed? Couldn't they just be concatenated? A .ts file should just be an MPEG, which Discord ought to support.

Relevant ffmpeg documentation

Rapougnac commented 2 months ago

They need, yeah, the .ts files are indeed MPEG files, but not MPEG-4 (or commonly called as mp4), they're MPEG-2 Transport Stream, which handle data differently than videos using MPEG-4 and therefore, isn't compatible with Discord. Trust me, if I could just concatenate the streams, I wouldn't bother remuxing the video. Hope my explanation makes sense.

mobiusscarf commented 2 months ago

Would using the copy codec for the audio as well as the video make it process any faster? Or does BlueSky do something weird for the audio as well?

Invertex commented 2 months ago

Would using the copy codec for the audio as well as the video make it process any faster?

Remuxing implies "copy" already, it's copying the video and audio streams into a different container layout, TS>MP4.

I wonder if perhaps a more lightweight library than FFMPEG could be used that's purely designed for TS to MP4 remux could be used that may perform a lot faster to fit in that request window... If such a thing exists. Or is the problem more so the time it takes the server to fetch the streams from BSKY first... Maybe Discord could be returned a file stream that remains open and Discord has to wait on that to finish, like how downloads from a server can be slowed to 0 but remain connected... But I'm not that versed in networking stuff.

Invertex commented 1 month ago

If it's any help, it looks like someone else managed to get full-length videos working in their version:

https://github.com/FerroEduardo/bskye

Can embed with bskye.app

(unless they're just letting it fail if it doesn't respond it time, but haven't bumped into that issue yet)

mobiusscarf commented 1 month ago

If it's any help, it looks like someone else managed to get full-length videos working in their version:

https://github.com/FerroEduardo/bskye

Can embed with bskye.app

(unless they're just letting it fail if it doesn't respond it time, but haven't bumped into that issue yet)

For some reason it's not embedding the text from my video posts, but the videos themselves all embed perfectly regardless of length. I took a glance at their source code and I don't think they're remuxing anything.

Invertex commented 1 month ago

For some reason it's not embedding the text from my video posts,

Seems like they just fixed that https://github.com/FerroEduardo/bskye/commit/9b38731f2b1e7fd6cba4e6796fa20026d7cd636e

And yeah interesting approach for getting the video.. Seems like there's an alternate sourcing method from bsky?

https://github.com/FerroEduardo/bskye/blob/9b38731f2b1e7fd6cba4e6796fa20026d7cd636e/src/util.ts#L191-L194

Invertex commented 1 month ago

Yeah can confirm, that handy API call returns a valid AVC1 MPEG-4 .mp4 file. So that should solve the issue! Hopefully they don't end up closing that API at some point haha

Rapougnac commented 1 month ago

Hi, sorry for the delay.

I was already aware of this endpoint, but this wasn't working on discord because their proxy stripped query parameters (like cid and did), but this seems now fixed, so this does indeed work now.

mary-ext commented 1 month ago

fwiw the approach taken here and the other embed site is very much discouraged, I've listed the reasons as to why bsky.app hasn't done video embedding here: https://github.com/bluesky-social/social-app/pull/5320#discussion_r1761001843