A simple video editing service using Node.js, Prisma, and FFmpeg. This application allows users to upload, trim, add subtitles, render final videos, and download them. All video data is stored in a PostgreSQL database and managed through Prisma.
- Upload videos: Users can upload videos, which will be stored and metadata (such as size, duration, and MIME type) is saved in the database.
- Trim videos: Users can specify start and end times to trim videos.
- Add subtitles: Users can add subtitles to a video.
- Render final video: After trimming or adding subtitles, the video can be rendered to create the final output.
- Download videos: Rendered videos can be downloaded.
- List all videos: View a list of all uploaded videos.
- Delete individual videos: Delete videos by ID.
- Delete all videos: Delete all videos and associated files.
Prerequisites
- Node.js
- Docker
- PostgreSQL (for database)
- FFmpeg (for video processing)
- Clone the repository:
git clone https://github.com/your-username/video-editor.git
cd video-editor- Install dependencies using pnpm/npm:
pnpm install
- Set up the database using Prisma: Run the following command to migrate the database schema:
pnpm prisma migrate dev
- Start the application:
pnpm start
- For PostgreSQL If using Docker, you can run the application using Docker Compose:
docker-compose up --build
The project contains various configuration files for setting up FFmpeg, Multer (for file upload handling), and the database connection.
-
src/configs/db.js: This file configures the PostgreSQL database connection using Prisma.
-
src/configs/ffmpeg.js: Configuration for FFmpeg to handle video processing tasks.
-
src/configs/multer.js: Middleware for handling video file uploads.
To run this project, you will need to add the following environment variables to your .env file
PORT
DATABASE_UTL:"postgresql://USER:password@port/videoeditor"
POST /api/videos/upload| Parameter | Type | Description |
|---|---|---|
video |
file |
Required. Video file to upload |
POST /api/videos/:id/trim| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Video ID to trim |
startTime |
string |
Required. Trim start time |
endTime |
string |
Required. Trim end time |
POST /api/videos/:id/subtitles| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Video ID to subtitle |
subtitles |
array |
Required. Array of subtitle objects (start, end, text) |
POST /api/videos/:id/render| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Video ID to render |
GET /api/videos/:id/download| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Video ID to download |
GET /api/videos/getvideos
| Parameter | Type | Description |
|---|---|---|
| None | — | Returns list of all uploaded videos |
DELETE /api/videos/:id/deletebyid| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Video ID to delete |
DELETE /api/videos/deleteallvideos
| Parameter | Type | Description |
|---|---|---|
| None | — | Deletes all videos |