Skip to content

Stonks3141/pet-monitor-app

Repository files navigation

pet-monitor-app

Repository crates.io CI License

Thanks to Nyx, who was able to obtain a copy of the H.264 standard for me.

pet-monitor-app is a simple video streaming server for Linux. It provides out-of-the-box support for HTTPS and password authentication.

Installation

Precompiled Binary

Download the binary and corresponding .sha256 file for your OS/architecture from the releases page. Run sha256sum --check pet-monitor-app-VERSION-TARGET.sha256 to verify the checksum. If it is correct, move the binary into /usr/local/bin.

Building from Source

Install rustup and run these commands:

git clone https://github.com/Stonks3141/pet-monitor-app.git
cd pet-monitor-app
cargo build --release
cp target/release/pet-monitor-app ~/.local/bin

If you have just installed, you can run just install after cloning.

Usage

Run these commands to start the server:

pet-monitor-app set-password
pet-monitor-app start

This first sets the password with the set-password subcommand, and then starts the server. You can view the page at http://localhost:8080. To reset your password, run the set-password subcommand again.

For a full list of command-line options, run with the --help flag or read the man page.

Running pet-monitor-app as root is not necessary and should be avoided. It is intended to be used in combination with a reverse proxy such as Nginx to provide HTTPS support and listen on low port numbers.

Configuration

The configuration file is located at ~/.config/pet-monitor-app/config.toml.

# The argon2 hash of the password
password_hash = '$argon2id$v=19$m=32768,t=8,p=4$19nFC/J5TEtjGGePEsLX+g$KmofOFmpLIBwqC7PkpHYyQyTiQF82IoBKanci2Dn5Ds'
# The secret used to sign authentication tokens
jwt_secret = 'DkTeDKts0tinlvmfUtbnepKqYHeX1B8w7sQ5LG9KW+s='
# The timeout for auth tokens in seconds
jwt_timeout = 345600
# The IP to listen on
host = '127.0.0.1'
# The port to listen on
port = 8080
# The device to capture video from
device = '/dev/video0'
# The format to capture video in
format = 'YUYV'
# The resolution to capture video in
resolution = [640, 480]
# The frame interval to use
# The framerate is equal to the first part divided by the second
interval = [1, 30]
# The video rotation (must be one of 0, 90, 180, or 270)
rotation = 0

# Additional V4L2 controls
[v4l2Controls]
foo = 0

Development

You will need to install rustup and just.

To start the server, run STATIC_RELOAD=1 cargo run -- start. The env var tells the server to read static assets from disk, they will be bundled into the binary otherwise.

To build the program, run cargo build --release. The binary should be located at target/release/pet-monitor-app.

Contributing

PRs are welcome. If you contribute code, try to add integration tests for any new functionality.

Inspiration

This project was inspired by soyersoyer/fmp4streamer.