4

How do I get a direct link to a video embedded in a tweet?

For example, the video embedded in this tweet can be watched directly here.

Note: I got the link from the Feedbro extension which can show an RSS-link feed of a twitter account. This is not a general solution, since it would only show the most recent 20 tweets and I need something that will work for an arbitrary twwet. It's just a demonstration that this is possible.

Note 2: This is not about downloading the video (there are multiple tools to do that), just retrieving a link to it.

Alex O
  • 595
  • 1
  • 6
  • 19

4 Answers4

8

youtube-dl is exactly what you need. Don't be fooled by its name, it works with a lot more than just youtube.

If you have youtube-dl installed, you can do it like so:

youtube-dl --get-url <link to media page>

It should print the video's URL in your terminal, and that's it!


Installation docs

5th
  • 81
  • 1
  • 2
  • If youtube-dl doesn't work try using the fork [YT-DLP](https://github.com/yt-dlp/yt-dlp) I've been having better luck lately with the fork version, it's up to date more. – TechLoom Jan 11 '23 at 17:45
3

I don't know the Technical anwser but there is a service that you can tag @SaveVidBot under the Video and it sends you a link and on the link you can click view and there is the direct media link.

Note: as per @persons's comment this no longer works

Edit: Now I did a bit of research. If you don't want to use an external service you can use the Chrome Debugger.

  1. Go to the Tweet with the Video for example this again

  2. Right-click anywhere on the page and hit Inspect

  3. Go to the Network Tab and hit F5 to reload the Network traffic from this site

  4. On the debugger search function search for ".mp4?tag"

  5. There should be only one result. Expand it and click it.

  6. Copy the Code from the Response Tab.

  7. In this code there is the direct link to the media in this case here

  8. You can use https://beautifier.io/ to make the code you copied easier to read.

Greenonline
  • 2,235
  • 11
  • 24
  • 30
Tobi-IT
  • 31
  • 2
  • 1
    That does it. Thank you! – Alex O Feb 14 '21 at 14:51
  • 6
    This no longer works, the website now only fetches an `.m3u8` playlist, and then fetches the chunks of the video separately as MPEG transport stream files (`.ts` extension). – Person Sep 20 '21 at 15:41
  • The complete `.mp4?tag` videos still exist, since I can get them from Slack's "Open Graph" previews of Twitter links. Just guessing, but I think Slack is hitting Twitter API's to get extended_entities for the tweet, and then client-side code transforms some of that into a URL that includes `ext_tw_video`. So probably still not easily available. – chronospoon Oct 24 '22 at 23:35
1

I ended up using the "Twitter Media Downloader for new Twitter.com 2019" user script from https://furyutei.github.io/twMediaDownloader/.

Direct link to the script: http://furyutei.github.io/twMediaDownloader/src/js/main_react.user.js

Alex O
  • 595
  • 1
  • 6
  • 19
  • Thanks! This worked perfectly and easily, and is the only solution I've found that works for private videos, since 3rd party services can't fetch them. – Personman Jun 23 '23 at 17:18
0

I've been using yt-dlp which is a fork of @5th's answer.

tl;dr Run this: yt-dlp https://twitter.com/[user]/status/[id] --output [user]-[id].mp4

It took a couple of tweaks to get a video to download nicely.

  1. You need to set the output filename otherwise it takes the whole tweet message and gives an error of 'too long filename'
  2. I suggest the 'http' rather than 'hls' format (I'm guessing hls is better for advanced users, but http complained less)

So here's the commands I used:

yt-dlp --list-formats https://twitter.com/omid9/status/1608389855909658626
yt-dlp --format http-2176 https://twitter.com/omid9/status/1608389855909658626 --output omid9-1608389855909658626.mp4
icc97
  • 577
  • 5
  • 20
  • 1
    `yt-dlp` automatically chooses the best format and `http-2176` is often use by default so `yt-dlp -o .mp4` should be enough in most case – 5th Jan 11 '23 at 11:00
  • 1
    Yeah, I think you're usually correct. It nice to be able to choose the format depending on what you're going to use it for, but given that most twitter Videos they'll be relatively small even at the largest size you ignore the `--format`. I'll simplify my answer. – icc97 Jan 11 '23 at 13:07