TikTok Live Recorder: Finally Got Live Streams Recording
I needed to archive TikTok live streams from creators I follow. The streams disappear after they end, and there's no built-in download feature. Here's the setup that records them automatically.
Why Recording TikTok Live Is Hard
TikTok live streams have several challenges:
- Dynamic URLs: Stream URLs change and expire quickly
- No API: TikTok doesn't provide an API for live streams
- Blob format: Streams use fragmented MP4 format
- Authentication: Some streams require login cookies
- Live detection: Need to know when a stream starts
tiktok-live-recorder handles most of this, but setup is tricky.
Problem
When trying to record a live stream, the recorder would fail to connect. The stream was definitely live (I could watch it in the app), but the recorder couldn't find it.
Error: Failed to connect to live stream: Connection timeout
What I Tried
Attempt 1: Used username only - Didn't work, needed unique ID
Attempt 2: Added cookies - Still failed, wrong region
Attempt 3: Used different TikTok domain - Worked!
Actual Fix
The issue was region-specific TikTok domains. tiktok-live-recorder defaults to the wrong region for some users:
# Install tiktok-live-recorder
pip install tiktok-live-recorder
# Record with explicit TikTok domain
tiktok-live-recorder -u @username --tiktok-domain www.tiktok.com
# For non-US accounts, try different domains:
tiktok-live-recorder -u @username --tiktok-domain www.tiktok.com
tiktok-live-recorder -u @username --tiktok-domain www.tiktok.com
tiktok-live-recorder -u @username --tiktok-domain www.tiktok.com
# With cookies (for private/follower-only streams)
tiktok-live-recorder -u @username --cookies sessionid=xyz
Problem
tiktok-live-recorder requires FFmpeg to record streams, but kept saying FFmpeg wasn't found even though I had it installed.
Error: FFmpeg not found. Please install FFmpeg to continue.
What I Tried
Attempt 1: apt install ffmpeg - Installed but recorder didn't see it
Attempt 2: Added FFmpeg to PATH - Still not found
Attempt 3: Specified FFmpeg path directly - Worked!
Actual Fix
Specify FFmpeg path explicitly or ensure it's in the system PATH:
# Check if FFmpeg is installed and in PATH
which ffmpeg
ffmpeg -version
# If not found, install:
# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg
# macOS
brew install ffmpeg
# Windows (using Chocolatey)
choco install ffmpeg
# Specify FFmpeg path to tiktok-live-recorder
tiktok-live-recorder -u @username --ffmpeg-path /usr/bin/ffmpeg
# Or add to PATH permanently
export PATH="/usr/bin:$PATH"
echo 'export PATH="/usr/bin:$PATH"' >> ~/.bashrc
Problem
Recordings were being saved to the current working directory instead of my designated downloads folder. Made it hard to organize recordings from multiple creators.
What I Tried
Attempt 1: Created symbolic link - Worked but messy
Attempt 2: Used absolute path in command - Forgot to include it every time
Actual Fix
Create a config file with persistent settings:
# Create config directory
mkdir -p ~/.config/tiktok-live-recorder
# Create config file
cat > ~/.config/tiktok-live-recorder/config.toml << 'EOF'
# TikTok-Live-Recorder Configuration
[Download]
# Save recordings to this directory
download_folder = "~/Videos/TikTok"
# Filename format: {username}_{timestamp}_{stream_id}.mp4
file_name_format = "{username}_{date}_{time}"
[Recording]
# Enable automatic recording
enable_auto_recording = true
# Record while offline (wait for stream to start)
record_if_offline = true
# Maximum recording duration (hours)
max_recording_duration = 4
[Quality]
# Video quality: HD, SD, or AUTO
quality = "HD"
# Enable audio
enable_audio = true
[Account]
# Optional: Add sessionid cookies for private streams
sessionid = ""
EOF
# Now recordings go to the specified folder
tiktok-live-recorder -u @username
What I Learned
- Lesson 1: Use @username format, not display names. The @ is required.
- Lesson 2: Region matters - if connection fails, try different TikTok domains.
- Lesson 3: FFmpeg must be in PATH or specified explicitly.
- Lesson 4: Config files save time - set up download folder and quality once.
- Overall: tiktok-live-recorder works great once configured, but the initial setup has several gotchas.
Automated Live Stream Monitoring
Python Script for Multiple Creators
import asyncio
import subprocess
from datetime import datetime
from typing import List
import os
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class TikTokLiveMonitor:
"""
Monitor multiple TikTok creators for live streams
and automatically record when they go live.
"""
def __init__(self, creators: List[str], download_dir: str = "~/Videos/TikTok"):
"""
Args:
creators: List of @usernames to monitor
download_dir: Directory to save recordings
"""
self.creators = creators
self.download_dir = os.path.expanduser(download_dir)
os.makedirs(self.download_dir, exist_ok=True)
async def check_and_record(self, username: str):
"""
Check if user is live and record if so
Args:
username: @username to check
"""
logger.info(f"Checking {username}...")
# Run tiktok-live-recorder with --record-if-offline flag
# This will wait for stream to start if offline
cmd = [
'tiktok-live-recorder',
'-u', username,
'--record-if-offline',
'--download-folder', self.download_dir,
'--tiktok-domain', 'www.tiktok.com'
]
try:
# Run recorder
process = await asyncio.create_subprocess_exec(
*cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
)
# Wait for process to complete
stdout, stderr = await process.communicate()
if process.returncode == 0:
logger.info(f"Successfully recorded {username}")
else:
logger.error(f"Error recording {username}: {stderr.decode()}")
except Exception as e:
logger.error(f"Exception checking {username}: {e}")
async def monitor_all(self, interval: int = 300):
"""
Monitor all creators periodically
Args:
interval: Check interval in seconds (default: 5 minutes)
"""
while True:
logger.info(f"Checking {len(self.creators)} creators...")
tasks = [
self.check_and_record(creator)
for creator in self.creators
]
# Run checks concurrently
await asyncio.gather(*tasks, return_exceptions=True)
# Wait before next check
logger.info(f"Waiting {interval}s before next check...")
await asyncio.sleep(interval)
# Usage
async def main():
# List of creators to monitor
creators = [
'@creator1',
'@creator2',
'@creator3'
]
monitor = TikTokLiveMonitor(
creators=creators,
download_dir='~/Videos/TikTok'
)
# Start monitoring (runs continuously)
await monitor.monitor_all(interval=300)
if __name__ == '__main__':
asyncio.run(main())
Cron Job for Periodic Checks
# Add to crontab with: crontab -e
# Check for live streams every 5 minutes
*/5 * * * * /usr/bin/python3 /path/to/tiktok_monitor.py >> /var/log/tiktok_monitor.log 2>&1
# Or use systemd service for more control
Production Setup That Works
#!/bin/bash
# tiktok_recorder.sh - Production recording script
set -e
# Configuration
CREATORS=("@creator1" "@creator2" "@creator3")
DOWNLOAD_DIR="$HOME/Videos/TikTok"
FFMPEG_PATH="/usr/bin/ffmpeg"
MAX_DURATION=14400 # 4 hours in seconds
# Create download directory
mkdir -p "$DOWNLOAD_DIR"
# Function to record a single creator
record_creator() {
local username="$1"
local timestamp=$(date +"%Y%m%d_%H%M%S")
local log_file="$DOWNLOAD_DIR/${username}_${timestamp}.log"
echo "[$(date)] Checking $username..."
tiktok-live-recorder \
-u "$username" \
--download-folder "$DOWNLOAD_DIR" \
--ffmpeg-path "$FFMPEG_PATH" \
--tiktok-domain www.tiktok.com \
--record-if-offline \
--max-recording-duration "$MAX_DURATION" \
2>&1 | tee "$log_file"
echo "[$(date)] Finished recording $username"
}
# Main loop
main() {
echo "Starting TikTok Live Recorder..."
echo "Monitoring ${#CREATORS[@]} creators"
while true; do
for creator in "${CREATORS[@]}"; do
record_creator "$creator"
done
# Wait 5 minutes before next check
echo "Waiting 5 minutes..."
sleep 300
done
}
# Run main function
main "$@"
Monitoring & Debugging
Check Recorder Status
# Check if recorder is running
pgrep -f tiktok-live-recorder
# View active recordings
ls -lh ~/Videos/TikTok/*.mp4
# Check disk space (recordings can be large)
df -h ~/Videos/TikTok
# Monitor log file
tail -f ~/.config/tiktok-live-recorder/recorder.log
Common Issues
- Connection fails: Try different --tiktok-domain values
- FFmpeg not found: Specify --ffmpeg-path explicitly
- Partial recordings: Check disk space and network stability
- Private streams: Need to add sessionid cookies
⚠️ Legal & Ethical Note
Recording live streams may violate TikTok's Terms of Service and copyright laws. Only record streams you have permission to archive. Respect creators' rights and content ownership. This article is for educational purposes only.