1 个不稳定版本
0.1.0 | 2023年2月7日 |
---|
135 在 多媒体
56 每月下载量
用于 pet-monitor-app
98KB
2.5K SLoC
pet-monitor-app
pet-monitor-app 是一个简单的 Linux 视频流服务器。它提供了开箱即用的 HTTPS 和密码认证支持。
安装
预编译的二进制文件
使用系统包管理器安装 libx264。从 发布页面 下载二进制文件和对应的 .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"
开发
要启动服务器,请运行 cargo run -- start
。在调试模式下,服务器将从磁盘读取客户端文件,而在发布模式下,它们将被打包到二进制文件中。
要构建程序,请运行 cargo build --release
。二进制文件应位于 target/release/pet-monitor-app
。
贡献
欢迎提交PR。如果您贡献代码,请尝试为任何新功能添加集成测试。
灵感
本项目受到soyersoyer/fmp4streamer的启发。
依赖项
~4.5–7.5MB
~142K SLoC