Sometimes it feels like my days consist of making neat looking screencaptures of the work that me and my team do on the web.
Android has a really nice utility built into the platform that allows you to
record the visual output of the device. The utility is called screenrecord
and
can be access via adb
over a USB cable. Extra details can be found on the
Android Developer site
Whilst it is a useful tool it can be cumbersome to use frequently because you have to connect your device, adb into it, issue the screenrecord command and then once complete copy the output video back to your local machine.
During the course of going through this process many times and sharing the videos I would also get a lot of complaints that the time was at a weird time, or that the battery was not full and it is was distracting. You can solve this by putting the device in to demo mode.
Because I have to do this frequently I created a little shell script that you can run that will make this process a lot easier. It will:
- Put the device into demo mode
- Set good default recording rates
- Start the recording
- Capture CTRL-C to finish recording and
- Remove demo mode
- Locally download the recorded video.
One nice benefit, if you have Google Photos all the videos can be automatically backed up and synced across devices (but that has nothing to do with this script).
if [ -z "$1" ]; then
shot_path=$(date +%Y-%m-%d-%H-%M-%S).mp4
else
shot_path="$*"
fi
trap ctrl_c INT
function ctrl_c() {
echo "** Trapped CTRL-C"
echo "** Downloading screencast"
sleep 2
adb shell am broadcast -a com.android.systemui.demo -e command exit
adb pull /sdcard/Movies/$shot_path .
alldone
}
function setup() {
adb shell settings put global sysui_demo_allowed 1
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype lte -e level 4
adb shell am broadcast -a com.android.systemui.demo -e command battery -e level 100 -e plugged false
adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4
# Tweak this if you want the clock to changed
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 0440
# Remove this if you want notifications to be availalbe
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false
echo When finished press CTRL-C
}
function alldone() {
adb shell am broadcast -a com.android.systemui.demo -e command exit
}
setup
adb shell screenrecord --bit-rate 6000000 /sdcard/Movies/$shot_path
echo "Finished"
In a later post I will describe the process of embedding the video in a device frame and also how we GIF them.
I lead the Chrome Developer Relations team at Google.
We want people to have the best experience possible on the web without having to install a native app or produce content in a walled garden.
Our team tries to make it easier for developers to build on the web by supporting every Chrome release, creating great content to support developers on web.dev, contributing to MDN, helping to improve browser compatibility, and some of the best developer tools like Lighthouse, Workbox, Squoosh to name just a few.
I love to learn about what you are building, and how I can help with Chrome or Web development in general, so if you want to chat with me directly, please feel free to book a consultation.
I'm trialing a newsletter, you can subscribe below (thank you!)