Last active
October 14, 2015 14:13
-
-
Save logankoester/9870284 to your computer and use it in GitHub Desktop.
Record, merge, and accelerate Android screen capture
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
#!/usr/bin/env bash | |
# Repeatedly records Android screen capture to files 180 seconds in length | |
# until Ctrl+C, then pulls those files to the desktop, merges them into | |
# one video, generates an additional 8x speed version (*-8x.mp4) and cleans | |
# up the intermediary files. | |
# Depends on: ffmpeg, adb | |
# Usage: $ adb-record <name> # => ./name.mp4 | |
trap ctrl_c INT | |
function ctrl_c() { | |
let MAX=COUNT+1 | |
let COUNT=0 | |
while [ $COUNT -lt $MAX ]; do | |
echo "Pulling /sdcard/$NAME-$COUNT.mp4 -> ./" | |
adb pull /sdcard/$NAME-$COUNT.mp4 ./ | |
echo "Adding ./$NAME-$COUNT.mp4 to ./$NAME.txt" | |
echo "file './$NAME-$COUNT.mp4'" >> ./$NAME.txt | |
echo "Removing /sdcard/$NAME-$COUNT.mp4" | |
adb shell rm /sdcard/$NAME-$COUNT.mp4 | |
let COUNT=COUNT+1 | |
export COUNT | |
done | |
echo "Concatenating files to ./$NAME.mp4" | |
ffmpeg -f concat -i ./$NAME.txt -c copy ./$NAME.mp4 | |
echo "Cleaning up" | |
rm -v ./$NAME-*.mp4 | |
rm -v ./$NAME.txt | |
echo "Copying at 8x speed (by dropping frames) to ./$NAME.mp4-8x.mp4" | |
ffmpeg -r:v "240/1" -i ./$NAME.mp4 -an -r:v "12/1" ./$NAME-8x.mp4 | |
break | |
} | |
COUNT=0 | |
export NAME=$1 | |
echo "Press CTRL+C to finish, pull and cat video" | |
for (( ; ; )) | |
do | |
echo "Recording to /sdcard/$NAME-$COUNT.mp4" | |
adb shell screenrecord --time-limit 180 --rotate /sdcard/$NAME-$COUNT.mp4 | |
let COUNT=COUNT+1 | |
export COUNT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment