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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/pylib/cmd_helper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 import logging
8 import optparse
9 import os
10 import signal
11 import sys
12 import time
13
14 from pylib import android_commands
15 from pylib import cmd_helper
16
17
18 def _GetTimestamp():
19 return time.strftime('%Y-%m-%d-%H%M%S', time.localtime())
20
21
22 def _PrintMessage(heading, eol='\n'):
23 sys.stdout.write('%s%s' % (heading, eol))
24 sys.stdout.flush()
25
26
27 def _CaptureAndPullVideo(adb, output):
28 video_file = '/sdcard/screen-recording.mp4'
29 host_file = output or 'screen-recording-%s.mp4' % _GetTimestamp()
30 host_file = os.path.join(os.path.curdir, host_file)
31
32 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.
33
34 _PrintMessage('Recording. Press Enter to stop...', eol='')
35 raw_input()
36
37 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
38 recorder.wait()
39
40 _PrintMessage('Downloading...', eol='')
41 adb.RunShellCommand('sync')
42 adb.PullFileFromDevice(video_file, host_file)
43 adb.RunShellCommand('rm -f "%s"' % video_file)
44 _PrintMessage('done')
45 _PrintMessage('Video written to %s' % os.path.abspath(host_file))
46
47
48 def main():
49 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
50 'Android (KitKat+) devices.')
51
52 parser.add_option('-o', '--output', help='Save video to file.')
53 parser.add_option('-v', '--verbose', help='Verbose logging.',
54 action='store_true')
55 options, args = parser.parse_args()
56
57 if options.verbose:
58 logging.getLogger().setLevel(logging.DEBUG)
59
60 adb = android_commands.AndroidCommands()
61 _CaptureAndPullVideo(adb, options.output)
62 return 0
63
64
65 if __name__ == '__main__':
66 sys.exit(main())
OLDNEW
« 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