#video-streaming #streaming #video #server #media #cli #config-file

bin+lib pet-monitor-app

适用于 Raspberry Pi 的简单安全的宠物监控程序

1 个不稳定版本

0.3.0 2023年2月12日

#230 in 多媒体

MIT 协议

79KB
1.5K SLoC

pet-monitor-app

Repository Release CI License

pet-monitor-app 是一个简单的 Linux 视频流服务器。它提供开箱即用的 HTTPS 和密码认证支持。

安装

预编译二进制文件

发布页面下载适用于您的操作系统/架构的二进制文件和相应的 .sha256 文件。运行 sha256sum --check pet-monitor-app-VERSION-TARGET.sha256 以验证校验和。如果正确,将二进制文件移动到 ~/.local/bin

从源代码构建

安装 rustup 并运行以下命令

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

如果您已安装 just,在克隆后可以运行 just install

使用

运行以下命令以启动服务器

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

这首先使用 set-password 子命令设置密码,然后启动服务器。您可以在 https://127.0.0.1:8080 上查看页面。要重置您的密码,请再次运行 set-password 子命令。

要获取完整的命令行选项列表,请使用 --help 标志运行。

配置文件位于 ~/.config/pet-monitor-app/config.toml。要启用 TLS,将以下内容添加到配置文件中

[tls]
port = 8443
cert = "path/to/cert.pem"
key = "path/to/key.key"

现在您可以在 https://127.0.0.1:8443 上查看页面。

无需以 root 身份运行 pet-monitor-app,应避免这样做。如果您的服务器需要监听端口 80 或 443,您应设置 NAT 转发,将外部端口 80 转发到内部端口 8080。如果无法这样做,请安装 nginx 并将其用于将端口 80 或 443 反向代理到 pet-monitor-app。

配置

~/.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 domain to serve from
domain = 'localhost'
# 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

# TLS configuration
[tls]
# The port to listen on for TLS
port = 8443
# Path to the SSL certificate
cert = "path/to/cert.pem"
# Path to the SSL certificate key
key = "path/to/key.key"

开发

您需要安装rustupjust

要启动服务器,运行STATIC_RELOAD=1 cargo run -- start。环境变量告诉服务器从磁盘读取静态资产,否则它们将被打包进二进制文件中。

要构建程序,运行cargo build --release。二进制文件应位于target/release/pet-monitor-app

贡献

欢迎提交PR。如果您贡献代码,请尝试为任何新功能添加集成测试。

灵感

该项目受到soyersoyer/fmp4streamer的启发。

依赖关系

~29–44MB
~793K SLoC