Mkdirs and hierarchy
This commit is contained in:
70
entrypoint.sh
Executable file
70
entrypoint.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#! /bin/bash
|
||||
|
||||
function main() {
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo "USAGE: $0 ip ip ip..." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
function clean() {
|
||||
kill -9 $(jobs -p)
|
||||
}
|
||||
trap clean EXIT ERR
|
||||
mkdirs &
|
||||
for ip in "$@"; do
|
||||
echo recording from $ip...
|
||||
record "$ip" &
|
||||
done
|
||||
|
||||
for i in "$@"; do
|
||||
if ! wait -n 1; then
|
||||
echo "Something died: $?" >&2
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
done
|
||||
}
|
||||
|
||||
function mkdirs() {
|
||||
while sleep 10; do
|
||||
mkdir -p "${OUT_DIR:-/tmp/ffmpeg_cap}/$(date +%Y)/$(date +%m)/$(date +%d)"
|
||||
done
|
||||
}
|
||||
|
||||
function record() {
|
||||
while true; do
|
||||
echo "starting record for $@"
|
||||
_record "$@"
|
||||
sleep 10
|
||||
done
|
||||
}
|
||||
|
||||
function _record() {
|
||||
local out="${OUT_DIR:-/tmp/ffmpeg_cap}/%Y/%m/%d/%H-%M-%S_$1.mp4"
|
||||
ffmpeg \
|
||||
-threads 0 \
|
||||
-nostdin \
|
||||
-nostats \
|
||||
-loglevel error \
|
||||
-i rtsp://192.168.0.$1:8554/unicast \
|
||||
-an \
|
||||
-map 0 \
|
||||
-force_key_frames "expr:gte(t,n_forced*9)" \
|
||||
-f segment \
|
||||
-segment_time ${SEG:-300} \
|
||||
-segment_format mp4 \
|
||||
-strftime 1 \
|
||||
-minrate .05k \
|
||||
-vcodec copy \
|
||||
"$out" \
|
||||
-vf "select=gt(scene\,0.003),setpts=N/(15*TB)" \
|
||||
< /dev/null \
|
||||
>> /tmp/ffmpegs.log \
|
||||
2>&1
|
||||
}
|
||||
|
||||
if [ "$0" == "$BASH_SOURCE" ]; then
|
||||
main "$@"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user