English | 简体中文
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.
- 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
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).
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.
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 pressing Ctrl + C
. And you can reattach to the logs by running docker compose logs -f
.
To stop the containers, run docker compose down
.
- Internet access, obviously 😂
- Git (optional, for cloning the repository)
- A java development kit (JDK) (version 17 or later), Amazon Corretto 17 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
)
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.
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.
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.
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.
Contributions are welcome! If you have any ideas, suggestions, or bug reports, please feel free to open an issue or a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.