Skip to content

Instantly share code, notes, and snippets.

@ryanmr

ryanmr/record.bash

Last active Aug 29, 2015
Embed
What would you like to do?
#!/bin/bash
# don't forget to include ADB in your path
# for example, in your ~/.bashrc, somewhere near the top
# export PATH=$PATH:/path/to/android-sdk/sdk/platform-tools
# check if there is a filename
if [ -z "$1" ]; then
echo usage: $0 filename
exit
fi
FILENAME=$1
# what to show when recording is stopped
control_c() {
echo -en "\n *** Stopping recording! *** \n"
echo -en "\n *** Use an Android File Explorer to access your video $FILENAME files on the device! *** \n"
exit $?
}
# trap the control-c interrupt
trap control_c SIGINT
# http://en.wikipedia.org/wiki/Bit_rate
BITRATE=9000000
COUNTER=0
MAXLENGTH=20
echo "At anytime, CTRL+C to stop the recording!"
# run the loop
while [ $COUNTER -lt $MAXLENGTH ]; do
TARGET=$1-$COUNTER.mp4
# echo "adb shell screenrecord --bit-rate "$BITRATE" --time-limit 180 /sdcard/"$TARGET
adb shell screenrecord --bit-rate $BITRATE --time-limit 180 "/sdcard/"$TARGET
let COUNTER=COUNTER+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment