stream-rec
stream-rec copied to clipboard
Automatic streaming record tool. 虎牙/抖音/斗鱼/Twitch/PandaTV直播,弹幕自动录制
English | 简体中文
Stream-rec
Stream-rec is an automatic stream recording tool for various streaming services.
It's powered by Kotlin, Ktor, and ffmpeg.
This project is the result of my personal need for a tool that can automatically record live streams and upload them to cloud storage.
[!NOTE]
This project is the result of my personal learning of Kotlin Coroutines, flow, Ktor, dao, repository pattern and other technologies.
Features
- Automatic stream recording, with configurable quality and format.
- Automatic file naming based on the stream title and start time.
- Automatic Danmu(Bullet comments) recording
- Persistent storage of stream and upload information (using SQLite)
- Integration with Rclone for uploading to cloud storage
- Configurable via web interface.
- Docker support
Supported streaming services
Service | Recording | Danmu | Url format |
---|---|---|---|
Douyin | ✅ | ✅ | https://www.live.douyin.com/{douyinId} |
Douyu | ✅ | ✅ | https://www.douyu.com/{room} |
Huya | ✅ | ✅ | https://www.huya.com/{room} |
PandaTV | ✅ | ✅ | https://www.pandalive.co.kr/live/play/{room} |
Twitch | ✅ | ✅ | https://www.twitch.tv/{room} |
AfreecaTv | ❌ | ❌ | |
Bilibili | ❌ | ❌ | |
Niconico | ❌ | ❌ | |
Youtube | ❌ | ❌ |
- More services will be supported in the future (if I have time, PRs are welcomed).
Screenshots
Installation
1. Docker Compose (Recommended)
1.1 Configuring the docker-compose.yml file
Create a docker-compose.yml
, take a look at the example configuration file.
Please read the comments in the configuration file for more information and make sure to modify crucial parts like passwords, paths, etc.
1.2 Running the Docker compose
Make sure you are in the same directory as the docker-compose.yml
file, then run the following command:
docker compose up -d && docker compose logs -f
Now, you are all set! You can access the web interface at http://localhost:15275
and start configuring the tool (
see Configuration).
[!NOTE]
You can detach from the logs by pressingCtrl + C
. And you can reattach to the logs by runningdocker compose logs -f
. To stop the containers, rundocker compose down
.
2. Building from source
2.1 Prerequisites
- Internet access, obviously 😂
- Git (optional, for cloning the repository)
- A java development kit (JDK) (version 21 or later), Amazon Corretto 21 is recommended.
-
FFmpeg (Make sure it's in your
PATH
). -
Streamlink (optional, for recording streams, make sure it's in your
PATH
) -
Rclone (optional, for uploading to cloud storage, make sure it's in your
PATH
) -
Sqlite3 (for storing stream, upload information, make sure it's in your
PATH
)
2.2 Building the backend
To build the project, first clone the repository and navigate to the root directory of the project.
git clone https://github.com/hua0512/stream-rec.git
cd stream-rec
Then, build the project using the following command:
./gradlew stream-rec:build -x test
The built fat jar file stream-rec.jar
will be located in the stream-rec/build/libs
directory.
2.2.1 Running the jar file
To run the jar file, use the following command:
java -jar stream-rec/build/libs/stream-rec.jar
Several environment variables can be set to configure the tool:
-
DB_PATH
: Path to the SQLite database folder. (default:./db
) -
JWT_SECRET
: Secret key for JWT token generation. -
LOG_LEVEL
: Log level (default:info
). -
LOGIN_SECRET
: Login password for the web interface (default:stream-rec
).
For example:
java -DDB_PATH=/path/to/your/db -DLOG_LEVEL=DEBUG -DJWT_SECRET=SECRET -DLOGIN_SECRET=123 -jar stream-rec/build/libs/stream-rec.jar
[!IMPORTANT]
Things to note:
- Please set the
LOGIN_SECRET
environment variable to a secure password. This password is used to log in to the web interface.- This password cannot be changed after the first run.
2.3 Building the frontend
Frontend is used to configure the tool, it's a simple web interface built with React.
Navigate to frontend repository and follow the build instructions.
After that, you can start configuring the tool by accessing the web interface at http://localhost:15275
. Take a look at
the Configuration page for more information.
Troubleshooting
Check logs under logs
directory, by default, it will be created in the same directory as the DB_PATH
.
- There´s a environment variable
LOG_LEVEL
that can be set todebug
to enable debug logs.
Contributing
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please feel free to open an issue or a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.