How to create your own Stream Recording Server and make a loop recording of your IP Camera (Full instruction)

If you’ve an IP Camera (or cameras) and want to loop record the stream it provides, or record a snapshot images at some intervals, or just both, then you’ve come to the right place!

Several day’s ago I’ve re-written my python project for stream recording and uploaded it on a public GitHub repo – https://github.com/SUXUMI/StreamRecordingServer.

Also I’ve prepared the docker image of it and here I’ll explain how it works.

1. Firstly, you’ll need to install docker & docker-compose

To do so, please follow this simple instructions based on your Operating System:

Install Docker Engine – https://docs.docker.com/engine/install/

Install Docker Compose – https://docs.docker.com/compose/install/

2. Next, you’ve to prepare a docker-compose file

Create a docker-compose.yml file and provide related environment variables.

version: '3.9'

services:
  stream-recording-server:
    image: suxumi/stream-recording-server:1
    volumes:
      - ./recordings:/recordings
    restart: always
    environment:
      CAM_NAME: 'Camera 1'
      CAM_RECORDINGS_PATH: '/recordings'
      CAM_VIDEO_STREAM: 'rtsp://user:pass@ip:554/live/ch0'
      CAM_RECORDINGS_MAX_SIZE: 1
      CAM_VIDEO_RECORDING_DURATION: 10
      CAM_VIDEO_RECORDING_FPS: 30
      CAM_IMAGE_STREAM: 'rtsp://user:pass@ip:554/live/ch0'
      CAM_IMAGE_INTERVAL: 10
      CAM_IMAGE_QUALITY: 15

In above I put all the possible variables you can provide.

Full description of each configuration options you can find here: github.com/SUXUMI/StreamRecordingServer#configuration

3. Build an image, up & run it

To build an image you’ve to simply run the next command:

$ sudo docker-compose up -d

On very first time it pull’s the image from docker hub, builds it for you locally and runs in detached mode.

And – That’s it – YOU’RE DONE! Your stream recording server is ready.

NOTE: every time you change configuration, you need to re-build the image, but at this time it will takes just a second as the main image was already pulled to your computer. To do so, use the next command:

$ sudo docker-compose up --build -d

Bonus

In case if you are not going to install docker or just do not want to user docker-compose for some reason, that’s ok, then just simply use my python app. Download it from the link below:

https://github.com/SUXUMI/StreamRecordingServer

But, don’t forget, in this case you need some prerequisites, such as:

  • Install python
  • Install required packages for python
  • Install ffmpeg
  • Provide related system environment variables
  • and finally, run the app.py

@source:
https://github.com/SUXUMI/StreamRecordingServer
https://hub.docker.com/r/suxumi/stream-recording-server

Leave a Reply