This is a RESTful server utilizing the ExpressJS framework to facilitate accessing video streams from an RTSP camera.
This is a Docker container-based solution that requires the host network driver to receive RTSP push from the camera.
The host networking driver only works on Linux hosts, and is not supported on Docker for Mac, Docker for Windows, or Docker EE for Windows Server.
So, we need other installation procedure to run locally
The server provides the following functionality:
- GET list (default: http://127.0.0.1:19612/list)
- It will output services JSON list
[
{
"id":"<service id - assign by system>",
"name":"<service name>",
"status":"<service status - 'Setup','Connecting','Active','NoSignal','End'>",
"url":"<Access detail service info include rtsp>:
}
]
//example:
[
{"id":0,"name":"Bunny","status":"Active","url":"http://127.0.0.1:19612/service/0"},
{"id":1,"name":"Color Bar","status":"Active","url":"http://127.0.0.1:19612/service/1"},
{"id":2,"name":"Invalid","status":"Connecting","url":"http://127.0.0.1:19612/service/2"}
]
- GET service/:id (default: http://127.0.0.1:19612/service/0)
- Outputs detailed service information in JSON format.
{
"ServiceID":"<service id>",
"Status":"<service status - 'Setup','Connecting','Active','NoSignal','End'>","ServiceName":"<service name>",
"stream":"<rtsp url to access the video forward by service>"
}
//example:
{"ServiceID":"0","Status":"Active","ServiceName":"Bunny","stream":"rtsp://127.0.0.1:6554/0"}
- By default, the application uses /express-docker/config.json stored in the image as config. Users can pass their configuration by specifying a custom JSON file. By
docker run --rm -it --network host --privileged -v <path of config.json>:/express-docker/config.json camera_route:latest
- service will use it's default config hardcode for any invalid config or config without services
- Json for config
{
"host": "ip address export for rtsp client to connect",
"port": 19612, // post for restful
"rtspPort": 6554, // rtsp server port for client to connecxt
"rtpPortStart": 10000,
"rtpPortCount": 10000,
"services":
[
{
"name": "<Service name with ASCII>",
"url": "rtsp://<user>:<password>@<rtsp server>/<video path>"
},
]
};
//example:
{
"host": "127.0.0.1",
"port": 19612,
"rtspPort": 6554,
"rtpPortStart": 10000,
"rtpPortCount": 10000,
"services":
[
{
"name": "Bunny",
"url": "rtsp://rtspstream:[email protected]/movie"
},{
"name": "Color Bar",
"url": "rtsp://rtspstream:[email protected]/pattern"
},{
"name": "Invalid",
"url": "rtsp://rtspstre111am:[email protected]/pattern"
}
]
}
Linux
- Make sure you have Docker installed.
- check out source code
- Update config.json
- Run
docker build -f Dockerfile.dev -t camera_route:latest .
to build container. - Run container
docker run --rm -it --network host --privileged camera_route:latest
Mac and Windows
- Make sure you have Node JS and NPM installed.
- check out source code
- Install ffmpeg Mac and Win
- Update config.json
- Run 'npm install' to install all require Package
- Run 'node index.js' under source code folder.
Go to your browser and access http://127.0.0.1:19612 to confirm the server is running. Use http://127.0.0.1:19612/list to list all available services.
- Add API for Deactivating Service, Adding/Dropping service while running, and using custom paths.
- Run without privileged mode.
- Run with Docker network host driver.
- Add test cases.
- Add a page to test RESTful API and play video.
- Port to work with https://github.com/bluenviron/mediamtx to support more codec without ffmpeg
- Config target codec and bitrate per service. Transcode source video it that's different.
- If you encounter any issues while running the containers, you can check the logs by running
docker logs [container-name]
. - If you continue to have trouble, please open an issue on the project's Github page.
If you want to contribute to this project, you can create a fork and send a pull request.
This project is licensed under the MIT License.