Created
July 12, 2019 07:54
-
-
Save asilchev/f126e7e95f54ead6a556d4a9ab1d1c02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
FFMPEG=/usr/bin/ffmpeg | |
# текущее время внизу видео | |
FILTER="drawtext=fontfile=/usr/share/fonts/liberation/LiberationSans-Regular.ttf: \ | |
text='%{localtime}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white :box=1:boxcolor=0x00000000@1" | |
# источник | |
SOURCE=rtsp://192.168.1.10:554/user=admin_password=PASSWORD_channel=1_stream=0.sdp | |
# интервал ожидания перед запуском нового процесса (сек.) | |
SLEEP_INTERVAL=40 | |
_log () { | |
echo "`date '+%d.%m.%Y %H:%M:%S'` $1" >> standalone.log | |
} | |
[ ! -f "$FFMPEG" ] && { echo "$FFMPEG not found."; exit 10; } | |
while true; do | |
_log "---" | |
_log "start recording, source: $SOURCE" | |
$FFMPEG -nostdin -i $SOURCE \ | |
-f segment -segment_time 10 -segment_format mp4 -reset_timestamps 1 \ | |
-vf "$FILTER" \ | |
-strftime 1 -c:v libx264 cam01-%Y%m%d-%H%M%S.mp4 | |
exit_code=$? | |
_log "stop recording, exit code: $exit_code" | |
_log "sleep $SLEEP_INTERVAL sec before restart recording" | |
sleep $SLEEP_INTERVAL | |
#test $? -gt 128 && break; #необходимо для завершения процесса по ctrl+c | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment