A microservices-based application that receives, processes, and stores information about MP4 files. Built with Node.js (API Service) and Go (Processing Service), communicating over NATS, with data stored in PostgreSQL. The system extracts the file data from MP4 files and stores the result for later use in video streaming piplines.
- Clone the repository:
git clone https://github.com/aditokmo/mp4-processor.git
cd mp4-processor- Create a
.envfile and copy from .env-example:
ENV files are needed in:
- root
- api
- processing-service
- Start the services with Docker Compose:
docker compose up --build-
Wait for the services to start.
- PostgreSQL database
- NATS message broker
- Node.js API service
- Go processing service
-
When services are started, open Postman and visit the API Documentation section.
- User sends a
POST /files/processrequest with an absolute path to an MP4 file on disk - API Service saves a record to the database with status PROCESSING
- API Service publishes a NATS message to the Processing Service
- Processing Service receives the message, opens the MP4 file, extracts the initialization file data (ftyp + moov boxes) and writes it to a new file, and saves it to
shared/outputfolder - Processing Service publishes the result back to the API Service via NATS
- API Service receives the result and updates the database record with status SUCCESSFUL or FAILED
- User can check the status and get the path to the processed file
The shared/ folder is already included in the repository with a test
MP4 file ready to use. Both services mount this folder automatically
with Docker Compose - no additional setup is required.
After cloning and running docker compose up --build, the folder
structure for videos and file output looks like this:
shared/
├── video.mp4
└── output/
Both the API Service and Processing Service access the same
/shared/ path inside their containers. When you submit
/shared/video.mp4 as the file path, both services can read
and write to this location.
To test with your own MP4 file, simply copy it into the shared/
folder and use its path in the request:
{
"path": "/shared/your-file.mp4"
}http://localhost:3000
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/files |
List all files |
GET |
/api/v1/files/:id |
Get single file details |
POST |
/api/v1/files/process |
Submit file for processing |
DELETE |
/api/v1/files/:id |
Delete file record |
curl -X GET http://localhost:3000/api/v1/filescurl -X GET http://localhost:3000/api/v1/files/123Replace 123 with the actual file ID.
curl -X POST http://localhost:3000/api/v1/files/process \
-H "Content-Type: application/json" \
-d '{"path": "/shared/video.mp4"}'Body required: JSON object with path field containing an absolute path to the MP4 file on disk.
curl -X DELETE http://localhost:3000/api/v1/files/123Replace 123 with the actual file ID.
| Service | Technology |
|---|---|
| API Service | Node.js, TypeScript, Express, Prisma |
| Processing Service | Go |
| Message Broker | NATS |
| Database | PostgreSQL |
| Containerization | Docker, Docker Compose |