Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Unified Diff: build/android/adb_record_screen.py

Issue 54123005: android: Add screen recording tool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/cmd_helper.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/adb_record_screen.py
diff --git a/build/android/adb_record_screen.py b/build/android/adb_record_screen.py
new file mode 100755
index 0000000000000000000000000000000000000000..0298a8c80e9bc5766fbc8db6b55a3805878d3793
--- /dev/null
+++ b/build/android/adb_record_screen.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import logging
+import optparse
+import os
+import signal
+import sys
+import time
+
+from pylib import android_commands
+from pylib import cmd_helper
+
+
+def _GetTimestamp():
+ return time.strftime('%Y-%m-%d-%H%M%S', time.localtime())
+
+
+def _PrintMessage(heading, eol='\n'):
+ sys.stdout.write('%s%s' % (heading, eol))
+ sys.stdout.flush()
+
+
+def _CaptureAndPullVideo(adb, output):
+ video_file = '/sdcard/screen-recording.mp4'
+ host_file = output or 'screen-recording-%s.mp4' % _GetTimestamp()
+ host_file = os.path.join(os.path.curdir, host_file)
+
+ recorder = cmd_helper.Popen(['adb', 'shell', 'screenrecord', video_file])
bulach 2013/11/04 16:59:44 -s serial?
Sami 2013/11/07 16:08:03 Done. (I went with -d/--device to match telemetry.
+
+ _PrintMessage('Recording. Press Enter to stop...', eol='')
+ raw_input()
+
+ recorder.send_signal(signal.SIGINT)
bulach 2013/11/04 16:59:44 iirc, this does not do what I thought it would ;)
Sami 2013/11/07 16:08:03 Thanks for pointing this out. Now I know why my vi
+ recorder.wait()
+
+ _PrintMessage('Downloading...', eol='')
+ adb.RunShellCommand('sync')
+ adb.PullFileFromDevice(video_file, host_file)
+ adb.RunShellCommand('rm -f "%s"' % video_file)
+ _PrintMessage('done')
+ _PrintMessage('Video written to %s' % os.path.abspath(host_file))
+
+
+def main():
+ parser = optparse.OptionParser(description='Record screen capture videos on '
bulach 2013/11/04 16:59:44 there's a "screenshot.py" already.. perhaps add a
Sami 2013/11/07 16:08:03 Great idea, I didn't know about screenshot.py. I'v
+ 'Android (KitKat+) devices.')
+
+ parser.add_option('-o', '--output', help='Save video to file.')
+ parser.add_option('-v', '--verbose', help='Verbose logging.',
+ action='store_true')
+ options, args = parser.parse_args()
+
+ if options.verbose:
+ logging.getLogger().setLevel(logging.DEBUG)
+
+ adb = android_commands.AndroidCommands()
+ _CaptureAndPullVideo(adb, options.output)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « no previous file | build/android/pylib/cmd_helper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698