Introduction to LiveRecorder
LiveRecorder is an automated live stream recording script designed to operate unattended. Powered by the robust capabilities of Streamlink, this application supports recording from multiple live streaming platforms. It leverages official APIs of these platforms to detect live stream starts through a polling mechanism, aiming to accomplish the most functions with minimal code.
Supported Platforms
LiveRecorder currently supports a wide range of platforms including:
- Bilibili
- Douyu
- Huya
- Douyin
- YouTube
- Twitch
- NicoNico
- TwitCasting
- Afreeca
- Pandalive
- Bigolive
- Pixiv Sketch
- Chaturbate
The support for more platforms is open for contributions through pull requests (PRs).
Important Notes
- It is not recommended to record too many live streams simultaneously due to potential unforeseeable issues.
- Some platforms, such as Pandalive, may have risk controls in place. Use cautiously.
- Given limited personal capacity, support for niche platforms might be problematic. Contributions for adding new platform support are welcome.
This script is meant strictly for unattended recording and does not plan to include features such as a user interface or recording segmentation, which can be addressed with post-processing software.
Known Bugs
- YouTube recordings may frequently interrupt when multiple streams from the same channel are running.
- Occasionally, Douyu live streams might encounter parsing errors due to its use of a JavaScript engine, but the script will automatically retry recording.
- Some users may experience screen distortion when recording on Bigolive, with the cause currently unknown.
Usage Instructions
Installing FFmpeg
To get started, install FFmpeg from the official download page for your operating system and add it to your system PATH to ensure global accessibility.
Download
LiveRecorder is supported on Windows, Mac, and Linux platforms (amd64 architecture). You can download the applicable executable from the release page. After downloading and extracting, modify the configuration file as needed and run the binary file directly.
Running Source Code
For unsupported platforms, you can run the source code. After installing Python, execute the following commands:
# Download the source code (if you don't have git, you can download the Source code from releases)
git clone https://github.com/auqhjjqdo/LiveRecorder.git
cd LiveRecorder
# Install dependencies
python3 -m pip install .
# Run the source code
python3 live_recorder.py
Configuration Details
The configuration file, config.json
, is located in the same directory as the executable. After modifying the example config.sample.json
, rename it to config.json
. Ensure that the file adheres strictly to JSON syntax by validating it on an online JSON formatter before making changes.
Proxy Configuration
The proxy
field specifies the proxy address and supports both HTTP and SOCKS proxies. The format is protocol://[user:password@]ip:port
, for example, http://127.0.0.1:7890
or socks5://admin:[email protected]:1080
. HTTP proxies are preferred due to existing compatibility issues with SOCKS5. If no proxy is required, set the value to null
without quotes or remove the field entirely.
Output Directory Configuration
The output
field indicates the directory for saving recorded files. This is optional (do not use an empty string) and defaults to the output
folder in the running directory. Use /
as the path separator to avoid compatibility issues. Both relative and absolute paths are supported, for example, output/video
, /tmp/output
, or D:/output
.
Live Recording Configuration
Modify the user
list according to the example, paying attention to commas, quotation marks, and indentations.
Field | Meaning | Acceptable Values | Required | Notes |
---|---|---|---|---|
platform | Live streaming platform | English or pinyin name of the platform | Yes | Must start with an uppercase letter |
id | User ID | The room number or username on the platform | Yes | Typically found in the streaming URL or as shown in examples |
name | Custom streamer name | Any characters | No | For differentiating recording files, defaults to id if blank |
interval | Detection interval | Any integer or decimal | No | Default interval is 10 seconds |
format | Output format | For example, ts , flv , mp4 , mkv , etc. | No | Defaults to the platform's stream format |
output | Output directory | Same as in Output Directory Configuration | No | Overrides general setting if provided |
proxy | Proxy | Same as in Proxy Configuration | No | Overrides general setting if provided |
headers | HTTP Headers | Refer to documentation | No | Useful for sites requiring header verification |
cookies | HTTP Cookie | key=value ; separate multiple cookies with ; | No | Necessary for streams requiring login |
Additional Notes
Bilibili Room Numbers
Some Bilibili streams display a short number in the URL instead of the true room number. To find the real room number, use the API: https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo?room_id=short_number
, and retrieve the number after room_id
.
Bilibili Quality
To watch higher-quality streams on Bilibili, an account is required. Include the cookies
field (only SESSDATA
is needed) to access the highest-definition streams.
Douyu Room Numbers
Similar to Bilibili, some Douyu streams show a short number as the room number. Use browser developer tools (F12), and enter room_id
in the console to get the actual number.
YouTube Channel IDs
Channel IDs typically begin with UC
, though YouTube allows custom identifiers, so URLs may not display the ID. Websites like this or this can help retrieve the ID.
NicoNico User and Channel IDs
NicoNico distinguishes between user and channel IDs with prefixes co
and ch
. However, streams typically use an lv
prefix for the video ID. To find the correct IDs, use the browser console command: NicoGoogleTagManagerDataLayer[0].content
. Note that some channels may only work with lv
video IDs due to existing issues.
TwitCasting Interval
TwitCasting uses a HTTP Keep-Alive connection to reduce TCP establishment overheads, but the server terminates the connection if no request is made within 10 seconds. Therefore, it's advisable to set the interval
below 10 seconds for TwitCasting streams to avoid protocol errors.
Output Files
Upon completion, recordings are packaged in the format specified in your configuration, using FFmpeg. The default video codec is generally H.264
, and the audio codec is AAC
, retaining maximum definition from the stream. Original files are deleted after packaging unless no output format is set.
The file naming format follows [YYYY.MM.DD HH.MM.SS][Platform][Streamer Name]Stream Title.Format
, using the system's default time zone settings.