Skip to content

Latest commit

 

History

History
81 lines (66 loc) · 2.57 KB

README.md

File metadata and controls

81 lines (66 loc) · 2.57 KB

Onvif Camera Mock

A project to emulate an onvif camera on the network and pass a custom RTSP stream through it.

Logo

Badges

Shell Script Python Docker CMake

Installation

Install git if not already done

  sudo apt install git

Clone the repository to you local computer

  sudo git clone https://github.com/IroN404/onvif-camera-mock

If not present, install Docker

On ubuntu 22.04

  # Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

#Install Docker packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Build the container from the root of the cloned repository (./onvif-camera-mock)

  docker build -t onvif-build -f ./build/Dockerfile.onvif-camera .

The build could take from 20 to 30 minutes.

Deployment

To deploy this project run

  docker run -it -e INTERFACE=eth0 -p 8554:8554 -p 1000:1000 docker-build

If you want to pass a custom mp4 file to the RTSP stream :

  docker run -it -e INTERFACE=eth0 -e MP4=/home/file.mp4 -p 8554:8554 -p 1000:1000 docker-build

After start you'll need to copy your MP4 file to the container, to do so, note the container id

    docker ps |grep onvif

Then copy

    docker cp <path/to/your/video/file> <container-id>:/home/file.mp4

Usage

You can now see the RTSP stream by using ffmpeg

apt install ffmpeg

The command is

ffplay rtsp://localhost:8554/stream1