Skip to content

Instantly share code, notes, and snippets.

@FranciscoG
Last active December 13, 2019 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FranciscoG/4eb62608a2678eb0348d793a07e58c32 to your computer and use it in GitHub Desktop.
Save FranciscoG/4eb62608a2678eb0348d793a07e58c32 to your computer and use it in GitHub Desktop.
Using adb to create screen recordings of all plugged in Android devices
#!/bin/bash
# TODO:
# - add option to change the time limit
# - add option to change the output folder
# - add option to delete recordings on device once they have been pulled
# - figure out how to kill script when everything is done
# how many seconds to record for
LIMIT=5
# where to send the file when it's done
FOLDER=~/Downloads/
timestamp=$(date +%Y-%m-%d-%H:%M:%S)
record () {
local d=$1
local f="/sdcard/${d}-${timestamp}.mp4"
echo "recording file ${f} for ${LIMIT} seconds"
(adb -s "$d" shell "screenrecord --time-limit ${LIMIT} ${f}")
wait
(adb -s "$d" pull "$f" "$FOLDER")
wait
open "$FOLDER"
}
adb devices | while read -r line
do
if [ ! "$line" = "" ] && [ "$(echo "$line" | awk '{print $2}')" = "device" ]
then
device=$(echo "$line" | awk '{print $1}')
record "$device" &
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment