This commit is contained in:
xyj 2023-12-02 13:22:57 +08:00
parent 912dd83005
commit 5dd7f5793e
3 changed files with 17 additions and 0 deletions

13
conf/record.conf Normal file
View File

@ -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

3
record.sh Executable file
View File

@ -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

View File

@ -12,6 +12,7 @@ def close_stream():
def exec_sh(msg): def exec_sh(msg):
cmd = json.loads(msg.payload.decode('utf-8'))["data"] cmd = json.loads(msg.payload.decode('utf-8'))["data"]
subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) subprocess.Popen([cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)