From 5dd7f5793e829977b44b5c084b25b8db63743122 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Sat, 2 Dec 2023 13:22:57 +0800 Subject: [PATCH] mqtt --- conf/record.conf | 13 +++++++++++++ record.sh | 3 +++ tool.py | 1 + 3 files changed, 17 insertions(+) create mode 100644 conf/record.conf create mode 100755 record.sh diff --git a/conf/record.conf b/conf/record.conf new file mode 100644 index 0000000..cb672a0 --- /dev/null +++ b/conf/record.conf @@ -0,0 +1,13 @@ +[program:record] +directory=/home/pi/lot_manager +command=/usr/bin/bash record.sh +user=pi +;是否随开机自启 或者reload自启动 +autostart=true +;失败重启 +autorestart=true +;重启次数 +restart_times=3 +redirect_stderr=true +stopsignal=TERM +stopasgroup=True diff --git a/record.sh b/record.sh new file mode 100755 index 0000000..d0a651b --- /dev/null +++ b/record.sh @@ -0,0 +1,3 @@ +#!/bin/bash +current_time=$(date +"%Y-%m-%d-%H-%M-%S") +ffmpeg -rtsp_transport tcp -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c:v libx265 -preset fast -crf 31 -c:a aac -vf scale=1920x1280:flags=lanczos -f mp4 segment -segment_time 900 file_$current_time.mp4 diff --git a/tool.py b/tool.py index 28242ff..dbeedae 100644 --- a/tool.py +++ b/tool.py @@ -12,6 +12,7 @@ def close_stream(): def exec_sh(msg): cmd = json.loads(msg.payload.decode('utf-8'))["data"] + subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)