-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_ac_vid_aud.sh
executable file
·40 lines (37 loc) · 1.27 KB
/
get_ac_vid_aud.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
set -e
if [ $# -lt 1 ]; then
echo "Usage $0 <recording ID>"
exit 1
fi
ID="$1"
TMP=$ID/tmp
if [ -z "$OUTDIR" ]; then
OUTDIR=/tmp/ac_output
fi
mkdir -p $OUTDIR
cd $OUTDIR
rm -rf $ID
mkdir -p $TMP
COOKIE=`curl -I "$AC_ENDPOINT/api/xml?action=login&login=$AC_USERNAME&password=$AC_PASSWD" | grep "Set-Cookie:" | awk -F " " '{print $2}'`
if [ ! -r $ID.zip ]; then
curl -q -b "$COOKIE" "$AC_ENDPOINT/$ID/output/$ID.zip?download=zip" > $ID.zip
fi
unzip -o -d $TMP $ID.zip
VOIP=($(ls $TMP/cameraVoip*.flv | sort --version-sort -f))
SCREENSHARE=($(ls $TMP/screenshare*.flv | sort --version-sort -f))
for i in "${!VOIP[@]}"; do
if ffprobe -v error -show_entries stream=codec_type ${VOIP[$i]} | grep -m1 -q "video\|audio"; then
FILENAME=$(printf "%0*d" 4 $i)
if [ -n "${SCREENSHARE[$i]}" ]; then
ffmpeg -nostdin -i "${VOIP[$i]}" -i "${SCREENSHARE[$i]}" -vcodec copy -acodec copy -y $ID/$FILENAME.flv
else
ffmpeg -nostdin -i "${VOIP[$i]}" -vcodec copy -acodec copy -y $ID/$FILENAME.flv
fi
fi
done
rm -f $ID.list
for f in $ID/*.flv; do echo "file '$PWD/$f'" >> $ID.list; done
OUTPUT_FILE=$OUTDIR/$ID.flv
ffmpeg -nostdin -f concat -safe 0 -i $ID.list -c copy -y $OUTPUT_FILE
echo "Final output saved to $OUTPUT_FILE"