A big brain approach to downloading tiktok livestreams

I recently found out that you can download tiktok lives with yt-dlp much easier now. Here’s a guide on how I do it.

I realize that there are much better ways to do this, but this is the best I could come up with since I don’t have a lot of experience using command line tools and don’t know how to integrate them in scripts.

What you need:

Once you installed both yt-dlp and ffmpeg, added them to the path and are able to run them from any folder, you need to follow the steps below to create a batch file:

  1. Create txt file and add this to it, change the username & save it:
yt-dlp https://www.tiktok.com/@USERNAME/live --wait-for-video 300
goto loop
  1. Change the txt file extension to bat

Make sure you have the file extension thing enabled

  1. Run the bat file

A cmd window will open when you open the file and if the user is not live, you will see this.

It will check if they went live once every 5 min and once they go live it will start downloading the stream. Once the live ends it will start checking for the live again, download their stream when they go live and repeat this loop until you close the cmd window.

The stream will be downloaded by default to the same folder where the batch file is stored.

The batch file creates a loop needed to keep downloading the stream.

Without it, the live will stop downloading and yt-dlp will no longer check if the user is live once the live ends or a guest joins/ leaves the stream.

You can create a batch file for each user you want to scan for and run it, but I’d advise against opening all of them at the same time. I opened 80 at once and my laptop froze :upside_down_face:

You should be able to run multiple cmd windows at the same time without bricking your machine (even 80), just don’t open all of them at once.

How to merge files:

When downloading streams, you might notice that you end up with multiple files. To merge them you can follow these steps:

  1. Create a text file with this inside it, name it stream and save it in the folder with the streams:
file ‘stream1.mp4’
file ‘stream2.mp4’
  1. Run this command in the folder with the stream parts:

ffmpeg -f concat -i stream.txt -c copy stream.mp4

How to fix playback issues:

ffmpeg should convert the stream to mp4 & fix any playback issues that the stream might have automatically, but if you cancel the cmd window or for various reasons the downloaded file has incorrect timestamps (it appears as 712 hour long or smth), you can use the following command to fix it:

ffmpeg -i “stream1.mp4” -c copy -bsf:v h264_mp4toannexb -avoid_negative_ts make_zero stream1_1.mp4

To run these commands from a specific folder, you need to open cmd from that folder, by typing cmd in the path bar and paste the command in cmd:

EDIT: You will get rate limited if you scan for too many streams at once or for long periods of time, which can be fixed by simply not scanning for 1-2 days. Not sure what the optimal number of users to scan for is, but definitely not 80 for 8h. I’d recommend trying to focus on users who actually go live so you don’t send a million requests/ hour to download streams from users who haven’t gone live in months.