master
bel 2020-04-11 03:16:00 +00:00
parent b076269c5d
commit 844e83a0f0
14 changed files with 123 additions and 41 deletions

18
Dockerfile Executable file
View File

@ -0,0 +1,18 @@
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29
RUN apk update \
&& apk add --no-cache \
ca-certificates \
ffmpeg \
bash
RUN mkdir -p /var/log
WORKDIR /main
COPY . .
ENV GOPATH=""
ENV MNT="/mnt/"
ENTRYPOINT ["bash", "/main/entrypoint.sh"]
CMD []

View File

@ -1,41 +0,0 @@
#! /bin/bash
echo to start: ${@:-83}
for i in "${@:-83}"; do
echo starting $i...
ffmpeg \
-threads 0 \
-nostdin \
-nostats \
-loglevel error \
-i rtsp://192.168.0.$i:8554/unicast \
-an \
-map 0 \
-force_key_frames "expr:gte(t,n_forced*9)" \
-f segment \
-segment_time ${SEG:-10} \
-segment_format mp4 \
-strftime 1 \
-minrate .05k \
-vcodec copy \
"/tmp/ffmpeg_cap/ffmpeg_capture-$i-%Y%m%d_%H%M%S.mp4" \
-vf "select=gt(scene\,0.003),setpts=N/(15*TB)" \
2>&1 \
< /dev/null \
| grep -vE 'RTP: missed|max delay reached. need to consume packet|decode_slice_header|no.frame|non.existing.PPS|Last.message.repeated' \
>> ./ffmpegs.log &
done
clean() {
kill -9 $(jobs -p)
}
trap clean EXIT ERR
for i in "${@:-83}"; do
if ! wait -n 1; then
echo "Something died" >&2
exit 1
fi
exit 0
done

60
run.sh Normal file
View File

@ -0,0 +1,60 @@
#! /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
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 record() {
while true; do
_record "$@"
sleep 10
done
}
function _record() {
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_DIR:-/tmp/ffmpeg_cap}/cap-$1-%Y%m%d_%H%M%S.mp4" \
-vf "select=gt(scene\,0.003),setpts=N/(15*TB)" \
< /dev/null \
>> /tmp/ffmpegs.log \
2>&1
}
if [ "$0" == "$BASH_SOURCE" ]; then
main "$@"
fi

View File

45
testdata/ffmpeg/run.sh vendored Normal file
View File

@ -0,0 +1,45 @@
#! /bin/bash
echo to start: ${@:-83}
for i in "${@:-83}"; do
echo starting $i...
(
while true; do
ffmpeg \
-threads 0 \
-nostdin \
-nostats \
-loglevel error \
-i rtsp://192.168.0.$i:8554/unicast \
-an \
-map 0 \
-force_key_frames "expr:gte(t,n_forced*9)" \
-f segment \
-segment_time ${SEG:-10} \
-segment_format mp4 \
-strftime 1 \
-minrate .05k \
-vcodec copy \
"/tmp/ffmpeg_cap/ffmpeg_capture-$i-%Y%m%d_%H%M%S.mp4" \
-vf "select=gt(scene\,0.003),setpts=N/(15*TB)" \
< /dev/null \
>> ./ffmpegs.log \
2>&1
sleep 30
done
) &
done
clean() {
kill -9 $(jobs -p)
}
trap clean EXIT ERR
for i in "${@:-83}"; do
if ! wait -n 1; then
echo "Something died" >&2
exit 1
fi
exit 0
done