B2G/QA/Manual Test/Video Capture

From New wiki
Jump to navigation Jump to search

Recording User Actions on Device

Since the implementation of Bug 1144103, it has been made possible to use adb screenrecord command on FxOS devices that have kitkat or later build. In python gaiatest, this has been implemented in Bug 1237069.

  • In order to perform video capture, the layers.screen-recording.enabled preference need to be set to True.
  • Then, with the adb installed and the device connected to pc via USB, one can issue a 'adb shell screenrecord /sdcard/<filename>' command to start the recording.
  • Press Ctrl-c to stop recording.
  • Then, pull the captured video file from the device via the command 'adb pull /sdcard/<filename> '

Please note that the maximum recording time is 180 seconds, and currently the FxOS device only supports the framerate of 15fps.

Following bash script automates above steps. Save below script, chmod +x it, and execute to use screenrecord command as well.

<source lang="bash">

  1. !/bin/bash
  1. source borrowed from http://adventuresinqa.com/2015/02/04/android-screen-recording-using-adb/
  1. pull pref, and push pref with screenrecoding enabled if not already present

PREFS_JS=$(adb shell echo -n "/data/b2g/mozilla/*.default")/prefs.js PREF_LINE='user_pref("layers.screen-recording.enabled", true);'

if [ -z "$1" ] then echo "Please provide the video filename" else echo "Pulling preferences: $PREFS_JS" adb pull $PREFS_JS


if grep "$PREF_LINE" prefs.js then echo "Pref is already set." else echo "Pref is not set, setting and restarting..." echo "$PREF_LINE" >> prefs.js adb shell stop b2g adb push prefs.js $PREFS_JS adb shell start b2g fi

# start recording adb shell screenrecord /sdcard/$1.mp4 &

# 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/$1.mp4

# Delete the video from the device adb shell rm /sdcard/$1.mp4

# Kill background process incase kill PID fails trap "kill 0" SIGINT SIGTERM EXIT fi </source>