Video.Middleware is an Express.js-based middleware designed to capture RTSP streams and process them into various formats, including JPEG images, Base64 strings, and MP4 videos.
-
RTSP Stream Capture: Connect to RTSP streams and capture frames.
-
Image Processing: Save frames as JPEG images.
-
Base64 Encoding: Convert frames to Base64 strings for easy transmission.
-
Video Recording: Record streams and save them as MP4 videos.
-
Configurable Intervals: Set custom intervals for frame capturing.
-
RESTful API: Control streaming operations via API endpoints.
-
Node.js (v14 or higher)
-
FFmpeg installed and added to system PATH
-
An RTSP stream source
Install dependencies with npm
git clone https://github.com/MDAmir159/Video.Middleware.git
cd Video.MiddlewareInstall dependencies:
npm installConfigure environment variables:
- Rename .env.example to .env:
cp .env.example .env- Update the .env file with your configurations
Start the server:
npm startThe server will start on the port specified in the .env file (default is 3000).
Video.Middleware/
├── controllers/ # Route handlers
├── public/ # Static files and outputs
├── routes/ # API routes
├── services/ # Core processing logic
├── utils/ # Utility functions
├── app.js # Main application file
├── package.json # Project metadata and scripts
└── .env # Environment configurations
-
GET /start: Initiates the RTSP stream processing.
-
GET /stop: Stops the RTSP stream processing.
-
GET /status: Retrieves the current status of the stream processing.
Note: Ensure proper authentication and validation in production environments.
To test the application:
Start the server.
-
Access http://localhost:3000/start to begin processing.
-
Access http://localhost:3000/status to check the status.
-
Access http://localhost:3000/stop to end processing.
-
Processed files will be saved in the public/outputs directory.
This project is licensed under the MIT License.
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.