뿯붿# OpenCut

[English](./README.md) | [中뿯施](./README.zh.md)

OpenCut is an open-source video editing and audio processing platform.

## Prerequisites

Before deploying OpenCut, you need to:

1. Visit [FreeSound.org](https://freesound.org/) and create an account
2. Create an API application in your account settings to get your client ID and API key
3. **Build the OpenCut web image from source** (see [OpenCut GitHub](https://github.com/OpenCut-app/OpenCut))

## Quick Start

1. Copy the example environment file:

   ```bash
   cp .env.example .env
   ```

2. **Required Configuration** - Edit `.env` and set these mandatory variables:
   - `POSTGRES_PASSWORD`: Database password (change from default!)
   - `SERVERLESS_REDIS_HTTP_TOKEN`: Random token for Redis HTTP interface
   - `OPENCUT_BETTER_AUTH_SECRET`: Random secret key for authentication
   - `OPENCUT_FREESOUND_CLIENT_ID`: Your FreeSound client ID
   - `OPENCUT_FREESOUND_API_KEY`: Your FreeSound API key

3. **Optional Configuration** - For transcription features, set:
   - `OPENCUT_CLOUDFLARE_ACCOUNT_ID`
   - `OPENCUT_R2_ACCESS_KEY_ID`
   - `OPENCUT_R2_SECRET_ACCESS_KEY`
   - `OPENCUT_R2_BUCKET_NAME`
   - `OPENCUT_MODAL_TRANSCRIPTION_URL`

4. Start the service:

   ```bash
   docker compose up -d
   ```

5. Access the web interface at <http://localhost:3100>

## Services

- `web`: The OpenCut web application
- `db`: PostgreSQL database
- `redis`: Redis cache
- `serverless-redis-http`: Redis HTTP interface for Upstash compatibility

## Configuration

### Version Configuration

- `POSTGRES_VERSION`: PostgreSQL version, default is `17`
- `REDIS_VERSION`: Redis version, default is `7-alpine`
- `SERVERLESS_REDIS_HTTP_VERSION`: Serverless Redis HTTP version, default is `latest`
- `OPENCUT_WEB_IMAGE`: OpenCut web image name, default is `opencut/web:latest`

### Port Configuration

- `POSTGRES_PORT_OVERRIDE`: PostgreSQL host port, default is `5432`
- `REDIS_PORT_OVERRIDE`: Redis host port, default is `6379`
- `SERVERLESS_REDIS_HTTP_PORT_OVERRIDE`: Redis HTTP interface host port, default is `8079`
- `OPENCUT_WEB_PORT_OVERRIDE`: Web application host port, default is `3100`

### Database Configuration

- `POSTGRES_USER`: Database username, default is `opencut`
- `POSTGRES_PASSWORD`: Database password, **required**
- `POSTGRES_DB`: Database name, default is `opencut`

### Redis Configuration

- `SERVERLESS_REDIS_HTTP_TOKEN`: Token for Redis HTTP interface, **required**

### Application Configuration

- `TZ`: Timezone, default is `UTC`
- `OPENCUT_BETTER_AUTH_URL`: Auth service URL, default is `http://localhost:3100`
- `OPENCUT_BETTER_AUTH_SECRET`: Auth secret key, **required**
- `OPENCUT_FREESOUND_CLIENT_ID`: FreeSound client ID, **required**
- `OPENCUT_FREESOUND_API_KEY`: FreeSound API key, **required**

### Optional Transcription Configuration

Leave these blank to disable auto-captioning:

- `OPENCUT_CLOUDFLARE_ACCOUNT_ID`: Cloudflare account ID
- `OPENCUT_R2_ACCESS_KEY_ID`: R2 access key ID
- `OPENCUT_R2_SECRET_ACCESS_KEY`: R2 secret access key
- `OPENCUT_R2_BUCKET_NAME`: R2 bucket name
- `OPENCUT_MODAL_TRANSCRIPTION_URL`: Modal transcription service URL

## Volumes

- `postgres_data`: PostgreSQL data storage

## Resource Limits

| Service               | CPU Limit | Memory Limit | CPU Reserved | Memory Reserved |
| --------------------- | --------- | ------------ | ------------ | --------------- |
| web                   | 2.00      | 2G           | 0.50         | 512M            |
| db                    | 2.00      | 1G           | 0.50         | 256M            |
| redis                 | 1.00      | 512M         | 0.25         | 128M            |
| serverless-redis-http | 1.00      | 256M         | 0.25         | 64M             |

## Security Notes

뿯⚽붿 **Important Security Recommendations:**

- **Change all default passwords and secrets** before deploying to production
- Use strong, randomly generated values for:
  - `POSTGRES_PASSWORD`
  - `SERVERLESS_REDIS_HTTP_TOKEN`
  - `OPENCUT_BETTER_AUTH_SECRET`
- Never commit `.env` file with real credentials to version control
- Consider setting up a reverse proxy with HTTPS for external access
- Restrict database and Redis ports to internal network in production
- Keep the FreeSound API keys secure

## Building from Source

Since OpenCut doesn't provide pre-built Docker images, you need to build it yourself:

```bash
# Clone the OpenCut repository
git clone https://github.com/OpenCut-app/OpenCut.git
cd OpenCut

# Build the web image
docker build -t opencut/web:latest -f apps/web/Dockerfile .

# Return to your compose directory and start services
cd /path/to/compose-anything/src/opencut
docker compose up -d
```

## Reference

- [Official OpenCut Repository](https://github.com/OpenCut-app/OpenCut)
- [Original docker-compose.yaml](https://github.com/OpenCut-app/OpenCut/blob/main/docker-compose.yaml)

## License

Please refer to the official OpenCut project for license information.
