| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Takes a screenshot or a screen video capture from an Android device.""" | 7 """Takes a screenshot or a screen video capture from an Android device.""" |
| 8 | 8 |
| 9 import logging | 9 import logging |
| 10 import optparse | 10 import optparse |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 | 22 |
| 23 def _CaptureScreenshot(device, host_file): | 23 def _CaptureScreenshot(device, host_file): |
| 24 host_file = device.old_interface.TakeScreenshot(host_file) | 24 host_file = device.old_interface.TakeScreenshot(host_file) |
| 25 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file)) | 25 _PrintMessage('Screenshot written to %s' % os.path.abspath(host_file)) |
| 26 | 26 |
| 27 | 27 |
| 28 def _CaptureVideo(device, host_file, options): | 28 def _CaptureVideo(device, host_file, options): |
| 29 size = tuple(map(int, options.size.split('x'))) if options.size else None | 29 size = tuple(map(int, options.size.split('x'))) if options.size else None |
| 30 recorder = screenshot.VideoRecorder(device, | 30 recorder = screenshot.VideoRecorder(device, |
| 31 host_file, | |
| 32 megabits_per_second=options.bitrate, | 31 megabits_per_second=options.bitrate, |
| 33 size=size, | 32 size=size, |
| 34 rotate=options.rotate) | 33 rotate=options.rotate) |
| 35 try: | 34 try: |
| 36 recorder.Start() | 35 recorder.Start() |
| 37 _PrintMessage('Recording. Press Enter to stop...', eol='') | 36 _PrintMessage('Recording. Press Enter to stop...', eol='') |
| 38 raw_input() | 37 raw_input() |
| 39 finally: | 38 finally: |
| 40 recorder.Stop() | 39 recorder.Stop() |
| 41 host_file = recorder.Pull() | 40 recorder.Pull(host_file) |
| 42 _PrintMessage('Video written to %s' % os.path.abspath(host_file)) | 41 _PrintMessage('Video written to %s' % os.path.abspath(host_file)) |
| 43 | 42 |
| 44 | 43 |
| 45 def main(): | 44 def main(): |
| 46 # Parse options. | 45 # Parse options. |
| 47 parser = optparse.OptionParser(description=__doc__, | 46 parser = optparse.OptionParser(description=__doc__, |
| 48 usage='screenshot.py [options] [filename]') | 47 usage='screenshot.py [options] [filename]') |
| 49 parser.add_option('-d', '--device', metavar='ANDROID_DEVICE', help='Serial ' | 48 parser.add_option('-d', '--device', metavar='ANDROID_DEVICE', help='Serial ' |
| 50 'number of Android device to use.', default=None) | 49 'number of Android device to use.', default=None) |
| 51 parser.add_option('-f', '--file', help='Save result to file instead of ' | 50 parser.add_option('-f', '--file', help='Save result to file instead of ' |
| (...skipping 29 matching lines...) Expand all Loading... |
| 81 | 80 |
| 82 if options.video: | 81 if options.video: |
| 83 _CaptureVideo(device, host_file, options) | 82 _CaptureVideo(device, host_file, options) |
| 84 else: | 83 else: |
| 85 _CaptureScreenshot(device, host_file) | 84 _CaptureScreenshot(device, host_file) |
| 86 return 0 | 85 return 0 |
| 87 | 86 |
| 88 | 87 |
| 89 if __name__ == '__main__': | 88 if __name__ == '__main__': |
| 90 sys.exit(main()) | 89 sys.exit(main()) |
| OLD | NEW |