FixTweet / FxTwitter

Fix broken Twitter/X embeds! Use multiple images, videos, polls, translations and more on Discord, Telegram and others
https://fxtwitter.com
MIT License
2.25k stars 65 forks source link

Twitter starting to serve HEVC video files #711

Open Cynosphere opened 3 months ago

Cynosphere commented 3 months ago

Example tweet, found in the wild: https://twitter.com/blephin_/status/1767231724621062406

dangeredwolf commented 3 months ago

Pushed a hotfix to exclude HEVC versions of media where possible. This still breaks https://twitter.com/blephin_/status/1767231724621062406 because it only is encoded in HEVC (which also means it doesn't work in Firefox at all)

But this will fix posts like https://twitter.com/denfaminicogame/status/1767329323206525435 where a lower quality h264 version is available

Invertex commented 3 months ago

Pushed a hotfix to exclude HEVC versions of media where possible. This still breaks https://twitter.com/blephin_/status/1767231724621062406 because it only is encoded in HEVC (which also means it doesn't work in Firefox at all)

There is still an avc1 fallback, the issue there is that for some reason Twitter isn't including it in the m3u8 for the amplify_video type uploads.

(These are the results I get for that specific Tweet)

So instead, when requesting the TweetDetail of a post, need to enumerate the variants and grab the mp4 entry that has avc1, instead of grabbing the m3u8

Edit: Ah it seems you already do enumerate the variants, having looked at the code now. So yeah just need to also ignore the m3u8 as well, but only if there is an AVC1 variant listed....

dangeredwolf commented 3 months ago

I appear to have implemented the fix improperly, stand by

dangeredwolf commented 3 months ago

Okay I pushed a better fix that filters it properly, my previous fix was incomplete and broke with the formats in a different order, oops

ThibaultVlacich commented 3 months ago

I'm getting a lot of videos where the embed doesn't work on the iOS app, is this the reason?

Clawthorn commented 3 months ago

I'm not sure if this is the exact same problem, but I'm encountering a video embed problem with Telegram.

The tweet in question: https://x.com/Dansgaming/status/1771528971722564063?s=20

When linked via fxtwitter the video don't embed correctly and instead just shows up as a photo. And when using a bot to embed the video, telegram's API errors out claiming the video supplied by FXTwitter is not a video file, or at least not a valid MP4.

The video that fxtwitter supplies: https://video.twimg.com/ext_tw_video/1771528865896185857/pu/vid/avc1/1920x1080/b1RrTEUFcdjXd2mu.mp4?tag=14

No idea if this is HEVC somehow leaking out or what's going on.

dangeredwolf commented 3 months ago

Telegram supports transcoding HEVC videos, might be 20 MB limit? I'll look at that tomorrow it's getting late here haha

kevosmin commented 3 months ago

I’m having an issue where the embed links don’t play for some reason, here’s a screen recording of it https://github.com/FixTweet/FxTwitter/assets/36827792/32269173-e1f2-415c-8b2b-929d3645f2fa

Cynosphere commented 3 months ago

I'm blaming Discord mobile being the buggy mess that it is, as it plays on desktop just fine.

ThibaultVlacich commented 2 months ago

I'm blaming Discord mobile being the buggy mess that it is, as it plays on desktop just fine.

In my experience it doesn't play properly on Desktop (Windows) also. Often when video doesn't work on Mobile, on Desktop it'll play, but impossible to seek into the video. If you click somewhere along the progress bar, the video restarts from 0.

Cynosphere commented 2 months ago

but impossible to seek into the video. If you click somewhere along the progress bar, the video restarts from 0.

If I remember correctly, this is caused by the lack of a specific HTTP header or something of the sort, I don't think it has to do at all with the format of the video.

dangeredwolf commented 2 months ago

but impossible to seek into the video. If you click somewhere along the progress bar, the video restarts from 0.

If I remember correctly, this is caused by the lack of a specific HTTP header or something of the sort, I don't think it has to do at all with the format of the video.

Discord calculates it based on the metadata length of the file. If the metadata length is incorrect, the seek bar will have weird behavior.

Delphox commented 2 weeks ago

FYI Discord started supporting HEVC videos as of yesterday (?), so if Twitter starts serving HEVC videos again (and also for videos from that timeframe, such as this one) the workaround is no longer necessary.

EDIT: just learned that they aren't playing properly on the Windows desktop client yet (despite playing fine on web, mobile and Mac desktop client), only the audio plays. It's probably some minor Electron issue and should hopefully be fixed by Discord soon.

EDIT2: they fixed the Windows Desktop client, HEVC videos play fine in all platforms now.