npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tiktok-live-recorder

v1.0.4

Published

TikTok LIVE stream recorder for Node.js. Capture any TikTok LIVE stream to MP4 with one command. HLS + FLV support, auto-rotate files, scheduled records, ffmpeg under the hood. 2026 edition.

Readme

tiktok-live-recorder

Record any TikTok LIVE stream to MP4 in one command.

CLI + SDK. HLS + FLV input. Uses ffmpeg under the hood. Schedule, monitor, auto-archive. 2026 edition.

npm downloads license


Three ways to use it

1. One-click (Windows)

Download start.bat, double-click. It installs the package + prompts for a username. Records the live to MP4 in the current folder.

2. One-click (macOS / Linux)

curl -fsSL https://raw.githubusercontent.com/tiktool/tiktok-live-recorder/main/start.sh | bash

3. CLI

npm i -g tiktok-live-recorder
tiktok-live-recorder streamer_username

No key. No config. Just run it.

4. Programmatic

import { TikTokLiveRecorder } from 'tiktok-live-recorder';

const rec = new TikTokLiveRecorder('streamer_username');
const { outFile, durationSec } = await rec.record({ quality: 'origin', maxDurationSec: 3600 });
console.log(`Saved ${durationSec}s to ${outFile}`);

Install

# CLI + library
npm i -g tiktok-live-recorder

# library only (programmatic use)
npm install tiktok-live-recorder

ffmpeg must be on PATH:

  • Windows: download from https://www.gyan.dev/ffmpeg/builds/ and add bin to PATH.
  • macOS: brew install ffmpeg
  • Linux: sudo apt install ffmpeg (Debian/Ubuntu) or sudo dnf install ffmpeg (Fedora).

CLI

tiktok-live-recorder <username> [options]

Options:
  -o, --out <file>         Output file (default: <username>-<timestamp>.mp4)
  -q, --quality <q>        origin | FULL_HD1 | HD1 | SD1 | SD2  (default: origin)
  -c, --container <ext>    mp4 | flv | ts | mkv  (default: mp4)
      --max <seconds>      Stop after N seconds
  -v, --verbose            Print ffmpeg output
  -h, --help               Show this help

Examples:

# Record at best quality
tiktok-live-recorder streamer

# Cap at 2 hours, save to a named file
tiktok-live-recorder streamer --out 2026-06-07.mp4 --max 7200

# Save as FLV (no remux)
tiktok-live-recorder streamer -q origin -c flv

# Verbose ffmpeg output
tiktok-live-recorder streamer -v

The CLI exits with code 2 when the user is offline so you can chain it in a watcher script:

while ! tiktok-live-recorder streamer; do sleep 30; done

SDK

Quick start

import { TikTokLiveRecorder } from 'tiktok-live-recorder';

const rec = new TikTokLiveRecorder('streamer');
const { outFile, durationSec } = await rec.record();
console.log(`Wrote ${outFile} (${durationSec}s)`);

Constructor

new TikTokLiveRecorder(uniqueId, options?)

| Option | Type | Default | Description | |---|---|---|---| | endpoint | string | https://api.tik.tools/webcast/stream_url | Override the URL resolver. | | apiKey | string | - | Optional API key for higher-quality endpoints. |

rec.resolve(): Promise<StreamSources>

Returns the available HLS / FLV URLs for the user without starting a recording.

const { live, hls, flv, title } = await rec.resolve();
if (!live) console.log('@user is offline.');
else console.log('HLS origin:', hls?.origin);

rec.record(options): Promise<{ outFile, durationSec }>

Capture to disk. Resolves when the stream goes offline, maxDurationSec hits, or the user hits Ctrl+C.

| Option | Type | Default | Description | |---|---|---|---| | outFile | string | <uniqueId>-<timestamp>.mp4 | Output path. | | quality | Quality | 'origin' | Preferred quality. Falls back to next available. | | container | Container | 'mp4' | mp4 / flv / ts / mkv. | | ffmpegPath | string | 'ffmpeg' | Override the ffmpeg binary location. | | rotateEverySec | number | - | Auto-rotate segment files every N seconds (planned). | | maxDurationSec | number | - | Stop after N seconds. | | verbose | boolean | false | Pipe ffmpeg stderr to stdout. | | onSegmentStart | (path) => void | - | Callback when a new segment file starts. | | onSegmentEnd | (path) => void | - | Callback when a segment file closes. |

Errors

import { StreamOfflineError, FfmpegMissingError } from 'tiktok-live-recorder';

try {
    await rec.record();
} catch (e) {
    if (e instanceof StreamOfflineError) console.log('not live');
    else if (e instanceof FfmpegMissingError) console.log('install ffmpeg');
    else throw e;
}

Recipes

Watch + record (poll every 30s, record automatically)

import { TikTokLiveRecorder, StreamOfflineError } from 'tiktok-live-recorder';

const rec = new TikTokLiveRecorder('streamer');

while (true) {
    try {
        const { outFile } = await rec.record();
        console.log(`captured ${outFile}`);
    } catch (e) {
        if (!(e instanceof StreamOfflineError)) throw e;
    }
    await new Promise(r => setTimeout(r, 30_000));
}

Batch record multiple creators

import { TikTokLiveRecorder, StreamOfflineError } from 'tiktok-live-recorder';

const usernames = ['a', 'b', 'c', 'd'];

await Promise.all(usernames.map(async (u) => {
    const rec = new TikTokLiveRecorder(u);
    try { await rec.record({ outFile: `${u}.mp4` }); }
    catch (e) { if (!(e instanceof StreamOfflineError)) console.error(u, e); }
}));

Time-capped clip

import { TikTokLiveRecorder } from 'tiktok-live-recorder';

const rec = new TikTokLiveRecorder('streamer');
await rec.record({ maxDurationSec: 60, outFile: 'clip.mp4' });

Custom ffmpeg pipeline (split segments)

import { TikTokLiveRecorder } from 'tiktok-live-recorder';
import { spawn } from 'child_process';

const rec = new TikTokLiveRecorder('streamer');
const { hls } = await rec.resolve();
if (!hls?.origin) throw new Error('no hls available');

spawn('ffmpeg', [
    '-i', hls.origin,
    '-c', 'copy',
    '-f', 'segment',
    '-segment_time', '600',
    '-reset_timestamps', '1',
    'streamer-%03d.mp4',
], { stdio: 'inherit' });

More ready-to-run recipes in examples/.


How it works

  1. The recorder asks https://api.tik.tools/webcast/stream_url?uniqueId=X for the user's current HLS / FLV URLs.
  2. The server checks live status + returns the URLs as JSON.
  3. The recorder spawns local ffmpeg, passes the URL as input, copies the bytes to disk. No re-encoding.

All bandwidth flows directly from TikTok's CDN to your disk - none of it touches our servers. We only handle the lightweight URL resolution.


Compatibility

  • Node.js >= 18 (native fetch, ES2022).
  • Works on Windows, macOS, Linux, Docker.
  • ESM + CommonJS dual published.
  • Requires ffmpeg on PATH.

License

MIT

This is an independent third-party project. Not affiliated with, endorsed by, or in any way officially connected to TikTok or ByteDance Ltd. "TikTok" is a trademark of ByteDance Ltd; the name appears here for search discoverability.