docker-android/src/record.sh

46 lines
1.2 KiB
Bash
Raw Normal View History

2017-07-14 19:40:14 +01:00
#!/bin/bash
function start() {
mkdir -p $VIDEO_PATH
2017-10-27 20:02:00 +01:00
name="$(date '+%d_%m_%Y_%H_%M_%S').mp4"
2017-07-14 19:40:14 +01:00
echo "Start video recording"
2017-10-27 20:02:00 +01:00
ffmpeg -video_size 1599x899 -framerate 15 -f x11grab -i $DISPLAY $VIDEO_PATH/$name -y
2017-07-14 19:40:14 +01:00
}
function stop() {
echo "Stop video recording"
2017-10-27 20:02:00 +01:00
kill $(ps -ef | grep ffmpeg | awk '{print $2}')
2017-07-14 19:40:14 +01:00
}
function auto_record() {
2017-10-27 20:02:00 +01:00
if [ $AUTO_RECORD ]; then
2017-07-14 19:40:14 +01:00
if [ ${AUTO_RECORD,,} = true ]; then
echo "Auto recording is enable. It will record the video automatically as soon as appium receive test scenario!"
# Check if there is test running
no_test=true
while $no_test; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
2017-10-27 20:02:00 +01:00
if [ -n $task ]; then
2017-07-14 19:40:14 +01:00
sleep .5
else
no_test=false
start
fi
done
# Check if test is finished
while [ $no_test = false ]; do
task=$(curl -s localhost:4723/wd/hub/sessions | jq -r '.value')
2017-10-27 20:02:00 +01:00
if [ -n $task ]; then
2017-07-14 19:40:14 +01:00
stop
else
sleep .5
fi
done
fi
fi
2017-10-27 20:02:00 +01:00
}
$@