-
-
Save uqmessias/7fd267b6a31fc98b320f00901ad4d04e to your computer and use it in GitHub Desktop.
Capture or record android screen, pull file to Mac when it's completed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Demo: https://www.youtube.com/watch?v=4GsUf5OQAlI | |
# capture screen of android device | |
andrdroidScreenCapture() { | |
curTime=`date +%Y-%m-%d-%H-%M-%S` | |
tmpeName="$curTime.png" | |
[[ -n $1 ]] && fileName=$1 || fileName=$tmpeName | |
devicePath="/sdcard/$tmpeName" | |
adb shell screencap -p $devicePath | |
adb pull $devicePath $fileName | |
adb shell rm $devicePath | |
} | |
export ADB_SHELL_SCREENRECORD_ARGS='--verbose --bit-rate 2000000' | |
# record screen of android device | |
androidScreenRecord() { | |
echo -e "\033[1m(press Ctrl-C to stop recording)\033[0m" | |
curTime=`date +%Y-%m-%d-%H-%M-%S` | |
tmpeName="$curTime.mp4" | |
[[ -n $1 ]] && fileName=$1 || fileName=$tmpeName | |
devicePath="/sdcard/$tmpeName" | |
adb shell screenrecord $ADB_SHELL_SCREENRECORD_ARGS $devicePath | |
sleep 1 # wait for video encoding finish | |
adb pull $devicePath $fileName | |
# Don't delete copy in device. | |
# adb shell rm $devicePath | |
open $fileName | |
} | |
function asc() { | |
if [[ -z $1 ]]; then | |
echo "Please provide a filename." | |
echo "Provideing .png extension for capturing the device screen, and providing .mp4 for recording the device screen." | |
return | |
fi | |
if [[ $1 == *.png ]]; then | |
andrdroidScreenCapture $1 | |
elif [[ $1 == *.mp4 ]]; then | |
androidScreenRecord $1 | |
else | |
echo "Filename with unknow extension, only .png and .mp4 are supported" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment