# How to download a video from twitter DMs using VLC / youtube-dl Original article: https://netdevops.me/2019/how-to-download-an-m3u/m3u8-playlist-stream-without-a-special-software/ this smol guide was written by [Scrimmy](https://twitter.com/scrimmypone) For whatever reason, Twitter doesn't let you easily download videos on both desktop and mobile, whether they're in a public tweet, or in your DMs At least for public tweets, there's various websites that let you paste in a tweet URL and it'll grab the video for you, but for DMs you can't really do that - so you'll have to extract the video by hand. This guide can only be followed on desktop, sorry mobile users! ## Get the video link ### Go to the DM Open Twitter in Firefox, Safari, Chrome, or any other browser which has developer tools (Inspect Element, etc.) Go to the DM where the video is, scroll up/down and find the video ![](https://i.imgur.com/yWSDJJV.png) Right click to the right of the video, and click Inspect Element, which will bring you as close to the video element in the dev tools as you can get from the start. Now there are two methods of how you can find the video elements from here: 1. Using the JS console - usually much easier, no need to sift through the HTML 2. Manually going through the HTML to find the video element - a bit of a pain, but a helpful fallback option I strongly recommend using Method 1 ### Method 1 - use the console To avoid having to sift through the code to find the video element, you can use the console to locate all video elements at once. Once you're in Inspect Element, you can either click on the "Console" tab, or you can hit ESC to open the console. After you've found the console, enter the following code and hit enter: ``` document.querySelectorAll('video') ``` ![](https://i.imgur.com/lRIWNp3.png) It should output one or more video tags (you might need to click the little arrow next to NodeList to show the video elements). Look for ones that have `dm_video` in their `src=` part. Those are the actual videos in your DMs. You might need to scroll to the right (or expand your browser if you can't scroll) to be able to see it. Now copy the link in `src=` - you should be able to just right click on the link and press "Copy Link". Continue to the "Using youtube-dl" section. ### Method 2 - Find the `<video>` element using Inspect Element If you can't use Method 1 for whatever reason, then you can try finding the video element by hand. This assumes you've just clicked Inspect Element and are still on the HTML inspector - not in the console. Now you'll need to look around for the video. You should be able to keep expanding each element (in some browsers you can just keep hitting the right arrow key), starting from the one Inspect Element brought you to. Eventually you'll reach an empty DIV, so you'll just expand the one below it. Twitter are assholes, so you don't get a direct MP4 link, you get a playlist/stream `m3u8` file, so you'll need to use a tool such as youtube-dl to download it ![](https://i.imgur.com/g4FUov3.png) ## Download the video link There are two methods to do this (at least for the simplicity of this guide). 1. Using VLC Player - more user friendly method using a GUI 2. Using `youtube-dl` - for advanced users - much faster to do, but requires using the command line Choose the one that suits you below ### Method 1 - Using VLC player to download the m3u8 link into an MP4 Open VLC player, and go to the menu `File -> Open Network` Paste the link you extracted earlier, and hit "Open" to make sure you've got the correct video link. If you do, open this menu again, if you don't, see previous sections and try a different video element. Assuming it's the correct video, open the Open Network window again, paste the link, and this time tick "Stream Output" ![](https://i.imgur.com/VDYaKTi.png) Click "Settings" next to Stream Output, make sure it's set to "File", and use the Browse button to choose where to save the video file. ![](https://i.imgur.com/I5UcBIm.png) If you're an advanced user, adjust the options as desired, otherwise continue: Now hit OK, and it should begin to stream the video, while downloading it to the file you selected. If all went well, you should now have the video downloaded to the file you selected, all done! ### Method 2 - Using youtube-dl to download the m3u8 into an MP4/MKV This method is for more advanced users, as it involves the command line tool `youtube-dl` #### Install youtube-dl if you haven't already. If you're on windows, see the github readme: https://github.com/ytdl-org/youtube-dl ``` # mac/linux/bsd pip3 install -U youtube-dl # on mac brew install youtube-dl ``` #### Run the command The basic command is below, you can change `somevideo` to the name of the video file you want to download it to, or rename it after - and change `URL_TO_VIDEO` to the URL of the m3u8 file you got earlier If you want a different format, for example, MKV, simply change `mp4` to `mkv` ``` youtube-dl -o 'somevideo.%(ext)s' --merge-output-format mp4 URL_TO_VIDEO ``` For example: ``` youtube-dl -o 'somevideo.%(ext)s' --merge-output-format mp4 https://video.twimg.com/dm_video/1564776735920586757/pl/aX9ftW-CIq7VOhGICt2S5rj0qkbO-OhD2Q1SOtkIa1w.m3u8\?variant_version\=1\&tag\=1\&container\=fmp4 ``` Congratulations! You now have the video downloaded in the current folder as an MP4 file! ## Thanks for reading! Parts of this guide were made with help from this article: https://netdevops.me/2019/how-to-download-an-m3u/m3u8-playlist-stream-without-a-special-software/ This guide was written by [Scrimmy](https://twitter.com/scrimmypone) - if it helped you out, maybe give me a follow :)