Skip to content

Instantly share code, notes, and snippets.

@tgehrs
Forked from FriendlyTester/AndroidRecord.sh
Last active June 20, 2016 14:04
Show Gist options
  • Save tgehrs/5b2fcdad1dbb5fb103add86b34c05b8d to your computer and use it in GitHub Desktop.
Save tgehrs/5b2fcdad1dbb5fb103add86b34c05b8d to your computer and use it in GitHub Desktop.
BASH script to record Android display and download/delete the video
function adb-screenrecord(){
#name the file
filename=screen_record_$(date +"%s").mp4
# start recording
adb shell screenrecord --bit-rate 6000000 /sdcard/$filename &
# Get its PID
PID=$!
# Upon a key press
read -p "Press [Enter] to stop recording..."
# Kills the recording process
kill $PID
# Wait for 3 seconds for the device to compile the video
sleep 3
# Download the video
adb pull /sdcard/$filename ~/Desktop/$filename
# Delete the video from the device
adb shell rm /sdcard/$filename
# Kill background process incase kill PID fails
trap "kill 0" SIGINT SIGTERM EXIT
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment