https://github.com/diogob/motion-streamer
Detects motion from a gstreamer libcamerasrc element and streams it from a Raspberry Pi to a file and network
https://github.com/diogob/motion-streamer
gstreamer haskell opencv raspberry-pi
Last synced: 2 months ago
JSON representation
Detects motion from a gstreamer libcamerasrc element and streams it from a Raspberry Pi to a file and network
- Host: GitHub
- URL: https://github.com/diogob/motion-streamer
- Owner: diogob
- License: bsd-3-clause
- Created: 2022-05-06T02:10:14.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-11T15:27:48.000Z (over 1 year ago)
- Last Synced: 2025-06-14T10:38:36.222Z (about 1 year ago)
- Topics: gstreamer, haskell, opencv, raspberry-pi
- Language: Haskell
- Homepage:
- Size: 76.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# motion-streamer
## Building from sources
There is no binary distribution yet, so you will need to download this repository and compile the sources.
I have not tested cross-compilation, so I currently install all dependencies in the RPi and compile there.
Also note that this was written based on my experience with the [Raspberry Pi OS](https://www.raspberrypi.com/software/) Bookworm, so in other operating systems your mileage may vary.
### Required packages to compile
```sh
apt install libgirepository1.0-dev libgstreamer1.0-dev llvm libnuma-dev gstreamer1.0-opencv
```
### Haskell compiler
While there is a package for `ghc` and `cabal-install` on Bookworm I had problems compiling under that version.
The software was tested using GHC 9.8.2 and cabal 3.12.1.0.
You can install from binary packages using [GHCup](https://www.haskell.org/ghcup/).
Once you install GHCup try the command `ghcup tui` for a neat terminal ui that will show you all compiler and tool versions available.
### Compile and run the application
```sh
cabal run motion-streamer
```
In case you see the error `motion-streamer: FactoryError` it is probably due to the lack of a `libcamerasrc` element in your gstreamer instalation.
To install libcamera on Raspberry Pi OS:
```sh
apt install gstreamer1.0-libcamera
```
To install libcamera from sources check their [getting started section](https://libcamera.org/getting-started.html)
You can still run without libcamera using a test pattern:
```sh
MS_TEST=true cabal run motion-streamer
```
You can also configure the host (defaults to "0.0.0.0") and port (defaults to 5000) for tcp video streaming:
```sh
MS_HOST=localhost MS_PORT=8080 cabal run motion-streamer
```
## Using the camera
Once you have the camera setup, you can run the application without the `MS_TEST` flag.
### Streaming the video captured by the camera
Unless you use the `MS_HOST` configuration, the camera will be streaming via TCP to all network interfaces.
To watch the stream from any computer where `rpi` is a hostname that points to the RPi running motion-streamer use `gstreamer-launch-1.0` (provided by the package `gstreamer1.0-tools`):
```sh
gst-launch-1.0 -v tcpclientsrc host=rpi port=5000 ! h264parse ! avdec_h264 ! autovideosink
```