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

Side by Side Diff: webrtc/tools/test_stubbed_loopback_video.py

Issue 2632323003: Script to start stubbed loopback video test with Espresso (Closed)
Patch Set: Fixed review comments Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 #
4 # Use of this source code is governed by a BSD-style license
5 # that can be found in the LICENSE file in the root of the source
6 # tree. An additional intellectual property rights grant can be found
7 # in the file PATENTS. All contributing project authors may
8 # be found in the AUTHORS file in the root of the source tree.
9
10 """
11 This script is the wrapper that starts a loopback call with stubbed video in
12 and out. It then analyses the video quality of the output video against the
13 reference input video.
14
15 It expect to be given the webrtc output build directory as the first argument
16 all other arguments are optional.
17
18 It assumes you have a Android device plugged in.
19 """
20
21 import argparse
22 import logging
23 import os
24 import shutil
25 import subprocess
26 import sys
27 import tempfile
28
29 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
30
kjellander_webrtc 2017/01/23 10:31:47 Remove blank line 30 and add another blank line ab
mandermo 2017/01/23 12:54:55 Done.
31 SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
32
33 logging.basicConfig(level=logging.INFO)
34
35
36 def _RunCommand(argv, **kwargs):
37 logging.info('Running %r', argv)
38 subprocess.check_call(argv, **kwargs)
39
40
41 def _ParseArgs():
42 parser = argparse.ArgumentParser(description='Start loopback video analysis.')
43 parser.add_argument('--source_dir', default=SRC_DIR,
44 help='The path to the WebRTC source directory. Default: %default.')
45 parser.add_argument('build_dir_android',
46 help='The path to the build directory for Android.')
47 parser.add_argument('--build_dir_x86',
48 help='The path to the build directory for building locally.')
49 parser.add_argument('--temp_dir',
50 help='A temporary directory to put the output.')
51
52 args = parser.parse_args()
53 return args
54
55
56 def main():
57 args = _ParseArgs()
58
59 source_dir = args.source_dir
60 build_dir_android = args.build_dir_android
61 build_dir_x86 = args.build_dir_x86
62 temp_dir = args.temp_dir
63 if not temp_dir:
64 temp_dir = tempfile.mkdtemp()
65 else:
66 if not os.path.exists(temp_dir):
67 os.makedirs(temp_dir)
68
69 if not build_dir_x86:
70 build_dir_x86 = os.path.join(temp_dir, 'LocalBuild')
71 _RunCommand(['gn', 'gen', build_dir_x86])
72 _RunCommand(['ninja', '-C', build_dir_x86, 'frame_analyzer'])
73
74 toolchain_dir = os.path.join(source_dir, 'tools-webrtc',
75 'video_quality_toolchain')
76
77 # Download ffmpeg and zxing.
78 download_script = os.path.join(toolchain_dir, 'download.py')
79 _RunCommand([download_script])
kjellander_webrtc 2017/01/23 10:31:47 Add sys.executable as the first argument in the li
mandermo 2017/01/23 12:54:55 Done.
80
81 # Run the Espresso code.
82 espresso_target = os.path.join(build_dir_android,
kjellander_webrtc 2017/01/23 10:31:47 Rename to test_script.
mandermo 2017/01/23 12:54:55 Done.
83 'bin', 'run_AppRTCMobileTestStubbedVideoIO')
84 _RunCommand([espresso_target])
kjellander_webrtc 2017/01/23 10:31:47 Add sys.executable
mandermo 2017/01/23 12:54:55 Done.
85
86 # Pull the output video.
87 test_video = os.path.join(temp_dir, 'test_video.y4m')
88 _RunCommand(['adb', 'pull', '/sdcard/output.y4m', test_video])
89
90 test_video_yuv = os.path.join(temp_dir, 'test_video.yuv')
91
92 ffmpeg_path = os.path.join(toolchain_dir, 'linux', 'ffmpeg')
93
94 def convert_video(input_video, output_video):
95 _RunCommand([ffmpeg_path, '-y', '-i', input_video, output_video])
96
97 convert_video(test_video, test_video_yuv)
98
99 reference_video = os.path.join(source_dir,
100 'resources', 'reference_video_640x360_30fps.y4m')
101
102 reference_video_yuv = os.path.join(temp_dir,
103 'reference_video_640x360_30fps.yuv')
104
105 convert_video(reference_video, reference_video_yuv)
106
107 # Run compare script.
108 compare_script = os.path.join(source_dir, 'webrtc', 'tools',
109 'compare_videos.py')
110 zxing_path = os.path.join(toolchain_dir, 'linux', 'zxing')
111
112 # The frame_analyzer binary should be built for local computer and not for
113 # Android
114 frame_analyzer = os.path.join(build_dir_x86, 'frame_analyzer')
115
116 frame_width = 640
117 frame_height = 360
118
119 stats_file_ref = os.path.join(temp_dir, 'stats_ref.txt')
120 stats_file_test = os.path.join(temp_dir, 'stats_test.txt')
121
122 _RunCommand([
123 compare_script, '--ref_video', reference_video_yuv,
kjellander_webrtc 2017/01/23 10:31:47 Add sys.executable
124 '--test_video', test_video_yuv, '--yuv_frame_width', str(frame_width),
125 '--yuv_frame_height', str(frame_height),
126 '--stats_file_ref', stats_file_ref,
127 '--stats_file_test', stats_file_test, '--frame_analyzer', frame_analyzer,
128 '--ffmpeg_path', ffmpeg_path, '--zxing_path', zxing_path])
129
130 shutil.rmtree(temp_dir)
131
132
133 if __name__ == '__main__':
134 sys.exit(main())
135
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698