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

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: Style fixes and sys.executable used to execute python scripts 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
30 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
31 SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
32
33
34 def _RunCommand(argv, **kwargs):
35 logging.info('Running %r', argv)
36 subprocess.check_call(argv, **kwargs)
37
38
39 def _ParseArgs():
40 parser = argparse.ArgumentParser(description='Start loopback video analysis.')
41 parser.add_argument('--source_dir', default=SRC_DIR,
42 help='The path to the WebRTC source directory. Default: %default.')
43 parser.add_argument('build_dir_android',
44 help='The path to the build directory for Android.')
45 parser.add_argument('--build_dir_x86',
46 help='The path to the build directory for building locally.')
47 parser.add_argument('--temp_dir',
48 help='A temporary directory to put the output.')
49
50 args = parser.parse_args()
51 return args
52
53
54 def main():
55 logging.basicConfig(level=logging.INFO)
56
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([sys.executable, download_script])
80
81 # Run the Espresso code.
82 test_script = os.path.join(build_dir_android,
83 'bin', 'run_AppRTCMobileTestStubbedVideoIO')
84 _RunCommand([sys.executable, test_script])
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 sys.executable, compare_script, '--ref_video', reference_video_yuv,
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