diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..c452a85
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,28 @@
+# Version Control
+**/.git
+
+# Development Configuration
+**/.env*
+**/docker-compose*.yml
+**/Dockerfile*
+
+# Documentation and Tests
+**/docs
+**/tests
+**/*.md
+
+# Build Artifacts and Cache
+**/__pycache__
+**/*.pyc
+**/*.log
+**/node_modules
+**/venv
+
+# IDE Files
+**/.vscode
+**/.idea
+
+# Static Assets (Adjust as needed)
+**/.iconset/
+**/*.icns
+assets/images
\ No newline at end of file
diff --git a/.env.example b/.env.example
index 7ae2b7f..2cedbb6 100644
--- a/.env.example
+++ b/.env.example
@@ -6,4 +6,7 @@ PLATFORM=desktop
HOST=127.0.0.1
# PORT: Web server port number (default: 6006)
-PORT=6006
\ No newline at end of file
+PORT=6006
+
+# Set timezone
+TZ=Asia/Shanghai
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..6e86f08
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,42 @@
+FROM python:3.12-slim AS builder
+
+WORKDIR /app
+
+# Install system dependencies for build
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ build-essential \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+# Install Python dependencies
+COPY requirements-web.txt .
+RUN pip install --no-cache-dir -r requirements-web.txt
+
+COPY . .
+RUN mkdir -p /app/logs /app/downloads
+
+# Final stage: production image
+FROM python:3.12-slim
+
+WORKDIR /app
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ ffmpeg \
+ tzdata \
+ curl \
+ gnupg \
+ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
+ && apt-get install -y --no-install-recommends nodejs \
+ && apt-get clean \
+ && rm -rf /var/lib/apt/lists/*
+
+# Set timezone
+ENV TZ=Asia/Shanghai
+RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo "$TZ" > /etc/timezone
+
+# Copy Python dependencies and project files from the builder stage
+COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
+COPY --from=builder /usr/local/bin /usr/local/bin
+COPY --from=builder /app/ ./
+
+CMD ["sh", "-c", "python main.py --web --host 0.0.0.0"]
\ No newline at end of file
diff --git a/README.md b/README.md
index d0cf5b4..bb9de27 100644
--- a/README.md
+++ b/README.md
@@ -4,9 +4,11 @@
-
+
+
+
-
+
@@ -16,10 +18,12 @@
+
StreamCap 是一个基于FFmpeg和StreamGet的多平台直播流录制客户端,覆盖 40+ 国内外主流直播平台,支持批量录制、循环监控、定时监控和自动转码等功能。
## ✨功能特性
+- **多端支持**:支持Windows/MacOS/Web运行
- **循环监控**:实时监控直播间状态,开播即录。
- **定时任务**:根据设定时间范围检查直播间状态。
- **多种输出格式**:支持 ts、flv、mkv、mov、mp4、mp3、m4a 等格式。
@@ -53,20 +57,73 @@ cd StreamCap
2.**安装依赖**:
```bash
+# 桌面端
pip install -r requirements.txt
-# 或者
-poetry install
+
+# Web端
+pip install -r requirements-web.txt
```
-3.**运行程序**:
-使用以下命令启动程序:
+3.**配置运行环境**:
+
+将.env.example示例配置文件复制一份并将文件重命名为.env
+
+```bash
+cp .env.example .env
+```
+
+4.**运行程序**:
+
+在Windows和macOS上默认以桌面程序的方式运行,使用以下命令启动程序:
```bash
python main.py
```
+修改 `.env` 文件,将 `PLATFORM` 的值改为 `web`,即可以Web方式运行。
+
+或者,无需修改配置文件,直接使用以下命令启动
+
+```bash
+# Linux请使用web方式运行
+
+python main.py --web
+```
+
+启动成功后,通过 `http://ip:6006` 访问。
+
如果程序提示缺少 FFmpeg,请访问 FFmpeg 官方下载页面[Download FFmpeg](https://ffmpeg.org/download.html),下载预编译的 FFmpeg 可执行文件,并配置环境变量。
+## 🐋容器运行
+
+本机无需Python环境运行,在运行命令之前,请确保您的机器上安装了 [Docker](https://docs.docker.com/get-docker/) 和 [Docker Compose](https://docs.docker.com/compose/install/)
+
+1.**快速启动**
+
+最简单方法是运行项目中的 [docker-compose.yml](https://github.com/ihmily/StreamCap/blob/main/docker-compose.yml) 文件,进入项目根目录后,只需简单执行以下命令(确保已经存在`.env`文件):
+
+```bash
+docker compose up
+```
+
+可选 `-d` 在后台运行。注意容器内时区问题,默认使用的是 `Asia/Shanghai` ,如需修改可以在.env文件配置。
+
+2.**停止容器实例**
+
+```bash
+docker compose stop
+```
+
+3.**构建镜像**
+
+Docker镜像仓库中代码版本可能不是最新的,如要运行本仓库主分支最新代码,可以本地自定义构建,通过修改 [docker-compose.yml](https://github.com/ihmily/StreamCap/blob/main/docker-compose.yml) 文件
+
+```bash
+docker build -t streamcap .
+```
+
+构建完成后,请先将docker-compose.yml文件中的镜像名称修改为 `streamcap` 后再使用`docker compose` 运行。
+
## 😺已支持平台
**国内平台(30+)**:
diff --git a/README_EN.md b/README_EN.md
index 7f0d666..f41b4bf 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -4,9 +4,11 @@
-
+
+
+
-
+
@@ -15,10 +17,12 @@
+
StreamCap is a multi-platform live stream recording client based on FFmpeg and StreamGet. It covers over 40 mainstream live streaming platforms both domestically and internationally, and supports features such as batch recording, loop monitoring, timed monitoring, and automatic transcoding.
## ✨Features
+- **Multi-Platform Support**: Compatible with Windows, macOS, and Web environments.
- **Loop Monitoring**: Real-time monitoring of live stream status. Recording starts immediately when a stream goes live.
- **Scheduled Tasks**: Checks live stream status within a set time range.
- **Multiple Output Formats**: Supports ts, flv, mkv, mov, mp4, mp3, m4a, and other formats.
@@ -52,21 +56,73 @@ cd StreamCap
2.**Install Dependencies**:
```bash
+# For desktop
pip install -r requirements.txt
-# or
-poetry install
+
+# For web
+pip install -r requirements-web.txt
```
-3.**Run the Program**:
+3.**Configure the Runtime Environment**:
-Use the following command to start the program:
+Copy the `.env.example` sample configuration file and rename it to `.env`
+
+```bash
+cp .env.example .env
+```
+
+4.**Run the Program**:
+
+On Windows and macOS, the program runs as a desktop application by default. Use the following command to start the program:
```bash
python main.py
```
+To run the program in web mode, modify the `.env` file and change the value of PLATFORM to web.
+
+Alternatively, you can run the program in web mode without modifying the configuration file by using the following command:
+
+```bash
+# On Linux, please run in web mode
+
+python main.py --web
+```
+
+After successful startup, access it via `http://ip:6006`.
+
If the program prompts that FFmpeg is missing, please visit the FFmpeg official download page [Download FFmpeg](https://ffmpeg.org/download.html) to download the precompiled FFmpeg executable files and configure the environment variables.
+## 🐋Docker Running
+
+No Python environment is required on your local machine. Before running the commands, ensure that you have installed [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/).
+
+1.**Quick Start**
+
+The simplest method is to run the [docker-compose.yml](https://github.com/ihmily/StreamCap/blob/main/docker-compose.yml) file in the project. Navigate to the project root directory and execute the following command (ensure the `.env` file exists):
+
+```bash
+docker compose up
+```
+
+You can use the `-d` flag to run in the background. Note that the default timezone in the container is `Asia/Shanghai`. If you need to change it, you can configure it in the `.env` file.
+
+2.**Stop Container Instances**:
+
+```bash
+docker compose stop
+```
+
+3.**Build the Image**:
+
+If the code in the Docker image repository is not the latest, you can build the image locally from the main branch of this repository by modifying the [docker-compose.yml](https://github.com/ihmily/StreamCap/blob/main/docker-compose.yml) file.
+
+```
+docker build -t streamcap .
+```
+
+After the build is complete, please modify the image name in the `docker-compose.yml` file to `streamcap` before running it with `docker compose`.
+
## 😺 Supported Platforms
**Domestic Platforms (30+)**:
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..74a51b1
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,25 @@
+
+services:
+ streamcap:
+ image: ihmily/streamcap
+ tty: true
+ ports:
+ - "${PORT:-6006}:${PORT:-6006}"
+ environment:
+ - PORT=${PORT:-6006}
+ - TZ=${TZ:-Asia/Shanghai}
+ volumes:
+ - ./logs:/app/logs
+ - ./config:/app/config
+ - ./downloads:/app/downloads
+ healthcheck:
+ test: ["CMD", "sh", "-c", "curl -f http://localhost:${PORT:-6006}/about"]
+ interval: 30s
+ timeout: 10s
+ retries: 3
+ networks:
+ - streamcap-network
+
+networks:
+ streamcap-network:
+ driver: bridge
\ No newline at end of file
diff --git a/main.py b/main.py
index bef2d12..7976dac 100644
--- a/main.py
+++ b/main.py
@@ -87,7 +87,7 @@ def main(page: ft.Page) -> None:
page.title = "StreamCap"
page.theme_mode = ft.ThemeMode.LIGHT
- is_web = platform == "web"
+ is_web = args.web or platform == "web"
setup_window(page, is_web)
app = App(page)
@@ -119,6 +119,7 @@ if __name__ == "__main__":
multiprocessing.freeze_support()
if args.web or platform == "web":
+ logger.debug("Running in web mode on http://" + args.host + ":" + str(args.port))
ft.app(
target=main,
view=ft.AppView.WEB_BROWSER,
@@ -127,5 +128,6 @@ if __name__ == "__main__":
assets_dir=ASSETS_DIR,
use_color_emoji=True,
)
+
else:
ft.app(target=main, assets_dir=ASSETS_DIR)