OLD | NEW |
---|---|
(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 import argparse | |
11 import os | |
12 import shutil | |
13 import subprocess | |
14 import sys | |
15 import tempfile | |
16 | |
17 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | |
18 | |
19 WEBRTC_DIR = os.path.normpath(SCRIPT_DIR + '/../../') | |
20 | |
21 def _ParseArgs(): | |
22 parser = argparse.ArgumentParser(description='Start loopback video analysis') | |
23 parser.add_argument('--source_dir', | |
24 default=WEBRTC_DIR, help='The path to the WebRTC source directory') | |
25 parser.add_argument('build_dir_android', | |
26 help='The path to the build directory for Android') | |
27 parser.add_argument('--build_dir_x86', | |
28 help='The path to the build directory for building locally') | |
29 parser.add_argument('--temp_dir', | |
30 help='A temporary directory to put the output') | |
31 | |
32 args = parser.parse_args() | |
33 return args | |
34 | |
35 def main(): | |
36 args = _ParseArgs() | |
37 | |
38 source_dir = args.source_dir | |
39 build_dir_android = args.build_dir_android | |
40 build_dir_x86 = args.build_dir_x86 | |
41 temp_dir = args.temp_dir | |
42 if not temp_dir: | |
43 temp_dir = tempfile.mkdtemp() | |
44 else: | |
45 if not os.path.exists(temp_dir): | |
46 os.makedirs(temp_dir) | |
47 | |
48 if not build_dir_x86: | |
ehmaldonado_webrtc
2017/01/17 16:02:36
Why not do the same with build_dir_android?
mandermo
2017/01/18 10:21:24
I got the impression that in the CI the android ve
| |
49 build_dir_x86 = temp_dir + '/LocalBuild' | |
ehmaldonado_webrtc
2017/01/17 16:02:36
Maybe use rather os.path.join() here and below to
mandermo
2017/01/18 10:21:24
Done.
| |
50 subprocess.check_call(['gn', 'gen', build_dir_x86]) | |
51 subprocess.check_call(['ninja', '-C', build_dir_x86, 'frame_analyzer']) | |
52 | |
53 # Download ffmpeg and zxing. | |
54 download_script = source_dir + \ | |
55 '/tools-webrtc/video_quality_toolchain/download.py' | |
56 subprocess.check_call([download_script]) | |
57 | |
58 # Run the Espresso code. | |
59 espresso_target = build_dir_android + \ | |
60 '/bin/run_AppRTCMobileTestStubbedVideoIO' | |
61 subprocess.check_call([espresso_target]) | |
62 | |
63 # Pull the output video. | |
64 test_video = temp_dir + '/test_video.y4m' | |
65 subprocess.check_call(['adb', 'pull', '/sdcard/output.y4m', test_video]) | |
66 | |
67 test_video_yuv = temp_dir + '/test_video.yuv' | |
68 | |
69 ffmpeg_path = source_dir + \ | |
70 '/tools-webrtc/video_quality_toolchain/linux/ffmpeg' | |
71 | |
72 def convert_video(input_video, output_video): | |
73 subprocess.check_call([ffmpeg_path, '-y', '-i', input_video, output_video]) | |
74 | |
75 # Convert the test video. | |
76 convert_video(test_video, test_video_yuv) | |
77 | |
78 reference_video = source_dir + '/resources/reference_video_640x360_30fps.y4m' | |
79 | |
80 reference_video_yuv = temp_dir + '/reference_video_640x360_30fps.yuv' | |
81 | |
82 # Convert the reference video. | |
83 convert_video(reference_video, reference_video_yuv) | |
84 | |
85 # Run compare script. | |
86 compare_script = source_dir + '/webrtc/tools/compare_videos.py' | |
87 zxing_path = source_dir + '/tools-webrtc/video_quality_toolchain/linux/zxing' | |
88 | |
89 # The frame_analyzer binary should be built for local computer and not for | |
90 # Android | |
91 frame_analyzer = build_dir_x86 + '/frame_analyzer' | |
92 | |
93 frame_width = 640 | |
94 frame_height = 360 | |
95 | |
96 stats_file_ref = temp_dir + '/stats_ref.txt' | |
97 stats_file_test = temp_dir + '/stats_test.txt' | |
98 | |
99 subprocess.check_call([ | |
100 compare_script, '--ref_video', reference_video_yuv, | |
101 '--test_video', test_video_yuv, '--yuv_frame_width', str(frame_width), | |
102 '--yuv_frame_height', str(frame_height), | |
103 '--stats_file_ref', stats_file_ref, | |
104 '--stats_file_test', stats_file_test, '--frame_analyzer', frame_analyzer, | |
105 '--ffmpeg_path', ffmpeg_path, '--zxing_path', zxing_path]) | |
106 | |
107 shutil.rmtree(temp_dir) | |
ehmaldonado_webrtc
2017/01/17 16:02:36
Just curious: Why request a temp_dir as a flag if
mandermo
2017/01/18 10:21:24
Maybe there is no need actually, I thought maybe t
kjellander_webrtc
2017/01/19 13:55:34
I thought it could be useful to pass ${ISOLATED_OU
| |
108 | |
109 if __name__ == '__main__': | |
110 sys.exit(main()) | |
111 | |
OLD | NEW |