Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 # | 3 # |
| 4 # Use of this source code is governed by a BSD-style license | 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 | 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 | 6 # tree. An additional intellectual property rights grant can be found |
| 7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
| 8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
| 9 | 9 |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 import subprocess | 12 import subprocess |
| 13 import sys | 13 import sys |
| 14 import time | 14 import time |
| 15 import glob | 15 import glob |
| 16 import re | 16 import re |
| 17 import shutil | |
| 17 | 18 |
| 18 # Used to time-stamp output files and directories | 19 # Used to time-stamp output files and directories |
| 19 CURRENT_TIME = time.strftime("%d_%m_%Y-%H:%M:%S") | 20 CURRENT_TIME = time.strftime("%d_%m_%Y-%H:%M:%S") |
| 20 | 21 |
| 22 | |
| 21 def _ParseArgs(): | 23 def _ParseArgs(): |
| 22 """Registers the command-line options.""" | 24 """Registers the command-line options.""" |
| 23 usage = 'usage: %prog [options]' | 25 usage = 'usage: %prog [options]' |
| 24 parser = optparse.OptionParser(usage=usage) | 26 parser = optparse.OptionParser(usage=usage) |
| 25 | 27 |
| 26 parser.add_option('--frame_width', type='string', default='1280', | 28 parser.add_option('--frame_width', type='string', default='1280', |
| 27 help='Width of the recording. Default: %default') | 29 help='Width of the recording. Default: %default') |
| 28 parser.add_option('--frame_height', type='string', default='720', | 30 parser.add_option('--frame_height', type='string', default='720', |
| 29 help='Height of the recording. Default: %default') | 31 help='Height of the recording. Default: %default') |
| 30 parser.add_option('--framerate', type='string', default='60', | 32 parser.add_option('--framerate', type='string', default='60', |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 # Find the device location including USB and USB Bus ID's. | 161 # Find the device location including USB and USB Bus ID's. |
| 160 device_string = '/sys/bus/usb/devices/usb*/**/**/video4linux/' | 162 device_string = '/sys/bus/usb/devices/usb*/**/**/video4linux/' |
| 161 ref_magewell_device = glob.glob('%s%s' % (device_string, ref_magewell)) | 163 ref_magewell_device = glob.glob('%s%s' % (device_string, ref_magewell)) |
| 162 test_magewell_device = glob.glob('%s%s' % (device_string, test_magewell)) | 164 test_magewell_device = glob.glob('%s%s' % (device_string, test_magewell)) |
| 163 | 165 |
| 164 magewell_usb_ports = [] | 166 magewell_usb_ports = [] |
| 165 | 167 |
| 166 # Figure out the USB bus and port ID for each device. | 168 # Figure out the USB bus and port ID for each device. |
| 167 ref_magewell_path = str(ref_magewell_device).split('/') | 169 ref_magewell_path = str(ref_magewell_device).split('/') |
| 168 for directory in ref_magewell_path: | 170 for directory in ref_magewell_path: |
| 169 | |
| 170 # Find the folder with pattern "N-N", e.g. "4-3" or \ | 171 # Find the folder with pattern "N-N", e.g. "4-3" or \ |
| 171 # "[USB bus ID]-[USB port]" | 172 # "[USB bus ID]-[USB port]" |
| 172 if re.match(r'^\d-\d$', directory): | 173 if re.match(r'^\d-\d$', directory): |
| 173 magewell_usb_ports.append(directory) | 174 magewell_usb_ports.append(directory) |
| 174 | 175 |
| 175 test_magewell_path = str(test_magewell_device).split('/') | 176 test_magewell_path = str(test_magewell_device).split('/') |
| 176 for directory in test_magewell_path: | 177 for directory in test_magewell_path: |
| 177 | |
| 178 # Find the folder with pattern "N-N", e.g. "4-3" or \ | 178 # Find the folder with pattern "N-N", e.g. "4-3" or \ |
| 179 # "[USB bus ID]-[USB port]" | 179 # "[USB bus ID]-[USB port]" |
| 180 if re.match(r'^\d-\d$', directory): | 180 if re.match(r'^\d-\d$', directory): |
| 181 magewell_usb_ports.append(directory) | 181 magewell_usb_ports.append(directory) |
| 182 | 182 |
| 183 print '\nResetting USB ports where magewell devices are connected...' | 183 # Abort early if no devices are found. |
| 184 | 184 if len(magewell_usb_ports) == 0: |
| 185 # Use the USB bus and port ID (e.g. 4-3) to unbind and bind the USB devices | 185 print 'No magewell devices found.' |
| 186 # (i.e. soft eject and insert). | 186 return False |
| 187 try: | 187 else: |
| 188 print '\nResetting USB ports where magewell devices are connected...' | |
| 189 # Use the USB bus and port ID (e.g. 4-3) to unbind and bind the USB devices | |
| 190 # (i.e. soft eject and insert). | |
| 188 for usb_port in magewell_usb_ports: | 191 for usb_port in magewell_usb_ports: |
| 189 echo_cmd = ['echo', usb_port] | 192 echo_cmd = ['echo', usb_port] |
| 190 unbind_cmd = ['sudo', 'tee', '/sys/bus/usb/drivers/usb/unbind'] | 193 unbind_cmd = ['sudo', 'tee', '/sys/bus/usb/drivers/usb/unbind'] |
| 191 bind_cmd = ['sudo', 'tee', '/sys/bus/usb/drivers/usb/bind'] | 194 bind_cmd = ['sudo', 'tee', '/sys/bus/usb/drivers/usb/bind'] |
| 192 | 195 |
| 193 # TODO(jansson) Figure out a way to call on echo once for bind & unbind | 196 # TODO(jansson) Figure out a way to call on echo once for bind & unbind |
| 194 # if possible. | 197 # if possible. |
| 195 echo_unbind = subprocess.Popen(echo_cmd, stdout=subprocess.PIPE) | 198 echo_unbind = subprocess.Popen(echo_cmd, stdout=subprocess.PIPE) |
| 196 unbind = subprocess.Popen(unbind_cmd, stdin=echo_unbind.stdout) | 199 unbind = subprocess.Popen(unbind_cmd, stdin=echo_unbind.stdout) |
| 197 echo_unbind.stdout.close() | 200 echo_unbind.stdout.close() |
| 198 unbind.communicate() | |
| 199 unbind.wait() | 201 unbind.wait() |
| 200 | 202 |
| 201 echo_bind = subprocess.Popen(echo_cmd, stdout=subprocess.PIPE) | 203 echo_bind = subprocess.Popen(echo_cmd, stdout=subprocess.PIPE) |
| 202 bind = subprocess.Popen(bind_cmd, stdin=echo_bind.stdout) | 204 bind = subprocess.Popen(bind_cmd, stdin=echo_bind.stdout) |
| 203 echo_bind.stdout.close() | 205 echo_bind.stdout.close() |
| 204 bind.communicate() | |
| 205 bind.wait() | 206 bind.wait() |
| 206 except OSError as e: | 207 if bind.returncode == 0: |
|
kjellander_webrtc
2017/03/14 21:20:07
When returncode != 0 we don't have a defined retur
janssonWebRTC
2017/03/15 08:48:40
Done.
| |
| 207 print 'Error while resetting magewell devices: ' + e | 208 print 'Reset done!\n' |
| 208 raise | 209 return True |
| 209 | |
| 210 print 'Reset done!\n' | |
| 211 | 210 |
| 212 | 211 |
| 213 def StartRecording(options, record_paths): | 212 def StartRecording(options, ref_file_location, test_file_location): |
| 214 """Starts recording from the two specified video devices. | 213 """Starts recording from the two specified video devices. |
| 215 | 214 |
| 216 Args: | 215 Args: |
| 217 options(object): Contains all the provided command line options. | 216 options(object): Contains all the provided command line options. |
| 218 record_paths(dict): key: value pair with reference and test file | 217 record_paths(dict): key: value pair with reference and test file |
| 219 absolute paths. | 218 absolute paths. |
| 220 """ | 219 """ |
| 221 ref_file_name = '%s_%s_ref.%s' % (options.app_name, CURRENT_TIME, | 220 ref_file_name = '%s_%s_ref.%s' % (options.app_name, CURRENT_TIME, |
| 222 options.video_container) | 221 options.video_container) |
| 223 ref_file_location = os.path.join(record_paths['ref_rec_location'], | 222 ref_file = os.path.join(ref_file_location, ref_file_name) |
| 224 ref_file_name) | |
| 225 | 223 |
| 226 test_file_name = '%s_%s_test.%s' % (options.app_name, CURRENT_TIME, | 224 test_file_name = '%s_%s_test.%s' % (options.app_name, CURRENT_TIME, |
| 227 options.video_container) | 225 options.video_container) |
| 228 test_file_location = os.path.join(record_paths['test_rec_location'], | 226 test_file = os.path.join(test_file_location, test_file_name) |
| 229 test_file_name) | |
| 230 | 227 |
| 231 # Reference video recorder command line. | 228 # Reference video recorder command line. |
| 232 ref_cmd = [ | 229 ref_cmd = [ |
| 233 options.ffmpeg, | 230 options.ffmpeg, |
| 234 '-v', 'error', | 231 '-v', 'error', |
| 235 '-s', options.frame_width + 'x' + options.frame_height, | 232 '-s', options.frame_width + 'x' + options.frame_height, |
| 236 '-framerate', options.framerate, | 233 '-framerate', options.framerate, |
| 237 '-f', options.recording_api, | 234 '-f', options.recording_api, |
| 238 '-i', options.ref_video_device, | 235 '-i', options.ref_video_device, |
| 239 '-pix_fmt', options.pixel_format, | 236 '-pix_fmt', options.pixel_format, |
| 240 '-s', options.frame_width + 'x' + options.frame_height, | 237 '-s', options.frame_width + 'x' + options.frame_height, |
| 241 '-t', options.ref_duration, | 238 '-t', options.ref_duration, |
| 242 '-framerate', options.framerate, | 239 '-framerate', options.framerate, |
| 243 ref_file_location | 240 ref_file |
| 244 ] | 241 ] |
| 245 | 242 |
| 246 # Test video recorder command line. | 243 # Test video recorder command line. |
| 247 test_cmd = [ | 244 test_cmd = [ |
| 248 options.ffmpeg, | 245 options.ffmpeg, |
| 249 '-v', 'error', | 246 '-v', 'error', |
| 250 '-s', options.frame_width + 'x' + options.frame_height, | 247 '-s', options.frame_width + 'x' + options.frame_height, |
| 251 '-framerate', options.framerate, | 248 '-framerate', options.framerate, |
| 252 '-f', options.recording_api, | 249 '-f', options.recording_api, |
| 253 '-i', options.test_video_device, | 250 '-i', options.test_video_device, |
| 254 '-pix_fmt', options.pixel_format, | 251 '-pix_fmt', options.pixel_format, |
| 255 '-s', options.frame_width + 'x' + options.frame_height, | 252 '-s', options.frame_width + 'x' + options.frame_height, |
| 256 '-t', options.test_duration, | 253 '-t', options.test_duration, |
| 257 '-framerate', options.framerate, | 254 '-framerate', options.framerate, |
| 258 test_file_location | 255 test_file |
| 259 ] | 256 ] |
| 260 print 'Trying to record from reference recorder...' | 257 print 'Trying to record from reference recorder...' |
| 261 ref_recorder = subprocess.Popen(ref_cmd, stderr=sys.stderr) | 258 ref_recorder = subprocess.Popen(ref_cmd, stderr=sys.stderr) |
| 262 | 259 |
| 263 # Start the 2nd recording a little later to ensure the 1st one has started. | 260 # Start the 2nd recording a little later to ensure the 1st one has started. |
| 264 # TODO(jansson) Check that the ref_recorder output file exists rather than | 261 # TODO(jansson) Check that the ref_recorder output file exists rather than |
| 265 # using sleep. | 262 # using sleep. |
| 266 time.sleep(options.time_between_recordings) | 263 time.sleep(options.time_between_recordings) |
| 267 print 'Trying to record from test recorder...' | 264 print 'Trying to record from test recorder...' |
| 268 test_recorder = subprocess.Popen(test_cmd, stderr=sys.stderr) | 265 test_recorder = subprocess.Popen(test_cmd, stderr=sys.stderr) |
| 269 test_recorder.wait() | 266 test_recorder.wait() |
| 270 ref_recorder.wait() | 267 ref_recorder.wait() |
| 271 | 268 |
| 272 # ffmpeg does not abort when it fails, need to check return code. | 269 # ffmpeg does not abort when it fails, need to check return code. |
| 273 assert ref_recorder.returncode == 0, ( | 270 if ref_recorder.returncode != 0 or test_recorder.returncode != 0: |
| 274 'Ref recording failed, check ffmpeg output and device: %s' | 271 # Cleanup recording directories. |
| 275 % options.ref_video_device) | 272 shutil.rmtree(ref_file_location) |
| 276 assert test_recorder.returncode == 0, ( | 273 shutil.rmtree(test_file_location) |
| 277 'Test recording failed, check ffmpeg output and device: %s' | 274 print 'Recording failed, check ffmpeg output.' |
| 278 % options.test_video_device) | 275 return False |
|
kjellander_webrtc
2017/03/14 21:20:07
I prefer the exception, it's much easier to read a
janssonWebRTC
2017/03/15 08:48:40
Done.
| |
| 276 else: | |
| 277 print 'Ref file recorded to: ' + os.path.abspath(ref_file) | |
| 278 print 'Test file recorded to: ' + os.path.abspath(test_file) | |
| 279 print 'Recording done!\n' | |
| 280 return FlipAndCropRecordings(options, test_file_name, test_file_location, | |
| 281 ref_file_name, ref_file_location) | |
| 279 | 282 |
| 280 print 'Ref file recorded to: ' + os.path.abspath(ref_file_location) | |
| 281 print 'Test file recorded to: ' + os.path.abspath(test_file_location) | |
| 282 print 'Recording done!\n' | |
| 283 return FlipAndCropRecordings(options, test_file_name, | |
| 284 record_paths['test_rec_location'], ref_file_name, | |
| 285 record_paths['ref_rec_location']) | |
| 286 | 283 |
| 287 | 284 |
| 288 def FlipAndCropRecordings(options, test_file_name, test_file_location, | 285 def FlipAndCropRecordings(options, test_file_name, test_file_location, |
| 289 ref_file_name, ref_file_location): | 286 ref_file_name, ref_file_location): |
| 290 """Performs a horizontal flip of the reference video to match the test video. | 287 """Performs a horizontal flip of the reference video to match the test video. |
| 291 | 288 |
| 292 This is done to the match orientation and then crops the ref and test videos | 289 This is done to the match orientation and then crops the ref and test videos |
| 293 using the options.test_crop_parameters and options.ref_crop_parameters. | 290 using the options.test_crop_parameters and options.ref_crop_parameters. |
| 294 | 291 |
| 295 Args: | 292 Args: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 '-v', 'error', | 326 '-v', 'error', |
| 330 '-s', options.frame_width + 'x' + options.frame_height, | 327 '-s', options.frame_width + 'x' + options.frame_height, |
| 331 '-i', os.path.join(test_file_location, test_file_name), | 328 '-i', os.path.join(test_file_location, test_file_name), |
| 332 '-vf', options.test_crop_parameters, | 329 '-vf', options.test_crop_parameters, |
| 333 '-c:a', 'copy', | 330 '-c:a', 'copy', |
| 334 cropped_test_file | 331 cropped_test_file |
| 335 ] | 332 ] |
| 336 | 333 |
| 337 ref_crop = subprocess.Popen(ref_video_crop_cmd) | 334 ref_crop = subprocess.Popen(ref_video_crop_cmd) |
| 338 ref_crop.wait() | 335 ref_crop.wait() |
| 339 print 'Ref file cropped to: ' + cropped_ref_file | 336 test_crop = subprocess.Popen(test_video_crop_cmd) |
| 337 test_crop.wait() | |
| 340 | 338 |
| 341 try: | 339 # ffmpeg does not abort when it fails, need to check return code. |
| 342 test_crop = subprocess.Popen(test_video_crop_cmd) | 340 if ref_crop.returncode != 0 or test_crop.returncode != 0: |
| 343 test_crop.wait() | 341 # Cleanup recording directories. |
| 342 shutil.rmtree(ref_file_location) | |
| 343 shutil.rmtree(test_file_location) | |
| 344 print 'Cropping failed, check ffmpeg output.' | |
| 345 return False | |
| 346 else: | |
| 347 print 'Ref file cropped to: ' + cropped_ref_file | |
| 344 print 'Test file cropped to: ' + cropped_test_file | 348 print 'Test file cropped to: ' + cropped_test_file |
| 345 print 'Cropping done!\n' | 349 print 'Cropping done!\n' |
| 346 | 350 |
| 347 # Need to return these so they can be used by other parts. | 351 # Need to return these so they can be used by other parts. |
| 348 cropped_recordings = { | 352 cropped_recordings = { |
| 349 'cropped_test_file' : cropped_test_file, | 353 'cropped_test_file' : cropped_test_file, |
| 350 'cropped_ref_file' : cropped_ref_file | 354 'cropped_ref_file' : cropped_ref_file |
| 351 } | 355 } |
| 352 | |
| 353 return cropped_recordings | 356 return cropped_recordings |
| 354 except subprocess.CalledProcessError as e: | |
| 355 print 'Something went wrong during cropping: ' + e | |
| 356 raise | |
| 357 | 357 |
| 358 | 358 |
| 359 def CompareVideos(options, recording_result): | 359 def CompareVideos(options, recording_result): |
| 360 """Runs the compare_video.py script from src/webrtc/tools using the file path. | 360 """Runs the compare_video.py script from src/webrtc/tools using the file path. |
| 361 | 361 |
| 362 Uses the path from recording_result and writes the output to a file named | 362 Uses the path from recording_result and writes the output to a file named |
| 363 <options.app_name + '_' + CURRENT_TIME + '_result.txt> in the reference video | 363 <options.app_name + '_' + CURRENT_TIME + '_result.txt> in the reference video |
| 364 recording folder taken from recording_result. | 364 recording folder taken from recording_result. |
| 365 | 365 |
| 366 Args: | 366 Args: |
| 367 options(object): Contains all the provided command line options. | 367 options(object): Contains all the provided command line options. |
| 368 recording_files_and_time(dict): key: value pair with the path to cropped | 368 recording_files_and_time(dict): key: value pair with the path to cropped |
| 369 test and reference video files | 369 test and reference video files |
| 370 """ | 370 """ |
| 371 print 'Starting comparison...' | 371 print 'Starting comparison...' |
| 372 print 'Grab a coffee, this might take a few minutes...' | 372 print 'Grab a coffee, this might take a few minutes...' |
| 373 cropped_ref_file = recording_result['cropped_ref_file'] | 373 cropped_ref_file = recording_result['cropped_ref_file'] |
| 374 cropped_test_file = recording_result['cropped_test_file'] | 374 cropped_test_file = recording_result['cropped_test_file'] |
| 375 compare_videos_script = os.path.abspath(options.compare_videos_script) | 375 compare_videos_script = os.path.abspath(options.compare_videos_script) |
| 376 rec_path = os.path.abspath(os.path.join( | 376 rec_path = os.path.abspath(os.path.join( |
| 377 os.path.dirname(recording_result['cropped_ref_file']))) | 377 os.path.dirname(recording_result['cropped_ref_file']))) |
| 378 result_file_name = os.path.join(rec_path, '%s_%s_result.txt') % ( | 378 result_file_name = os.path.join(rec_path, '%s_%s_result.txt') % ( |
| 379 options.app_name, CURRENT_TIME) | 379 options.app_name, CURRENT_TIME) |
| 380 | 380 |
| 381 # Find the crop dimensions (950 and 420) in the ref crop parameter string: | 381 # Find the crop dimensions (e.g. 950 and 420) in the ref crop parameter |
| 382 # 'hflip, crop=950:420:130:56' | 382 # string: 'hflip, crop=950:420:130:56' |
| 383 for param in options.ref_crop_parameters.split('crop'): | 383 for param in options.ref_crop_parameters.split('crop'): |
| 384 if param[0] == '=': | 384 if param[0] == '=': |
| 385 crop_width = param.split(':')[0].split('=')[1] | 385 crop_width = param.split(':')[0].split('=')[1] |
| 386 crop_height = param.split(':')[1] | 386 crop_height = param.split(':')[1] |
| 387 | 387 |
| 388 compare_cmd = [ | 388 compare_cmd = [ |
| 389 sys.executable, | 389 sys.executable, |
| 390 compare_videos_script, | 390 compare_videos_script, |
| 391 '--ref_video', cropped_ref_file, | 391 '--ref_video', cropped_ref_file, |
| 392 '--test_video', cropped_test_file, | 392 '--test_video', cropped_test_file, |
| 393 '--frame_analyzer', os.path.abspath(options.frame_analyzer), | 393 '--frame_analyzer', os.path.abspath(options.frame_analyzer), |
| 394 '--zxing_path', options.zxing_path, | 394 '--zxing_path', options.zxing_path, |
| 395 '--ffmpeg_path', options.ffmpeg, | 395 '--ffmpeg_path', options.ffmpeg, |
| 396 '--stats_file_ref', os.path.join(os.path.dirname(cropped_ref_file), | 396 '--stats_file_ref', os.path.join(os.path.dirname(cropped_ref_file), |
| 397 cropped_ref_file + '_stats.txt'), | 397 cropped_ref_file + '_stats.txt'), |
| 398 '--stats_file_test', os.path.join(os.path.dirname(cropped_test_file), | 398 '--stats_file_test', os.path.join(os.path.dirname(cropped_test_file), |
| 399 cropped_test_file + '_stats.txt'), | 399 cropped_test_file + '_stats.txt'), |
| 400 '--yuv_frame_height', crop_height, | 400 '--yuv_frame_height', crop_height, |
| 401 '--yuv_frame_width', crop_width | 401 '--yuv_frame_width', crop_width |
| 402 ] | 402 ] |
| 403 | 403 |
| 404 try: | 404 try: |
| 405 with open(result_file_name, 'w') as f: | 405 with open(result_file_name, 'w') as f: |
| 406 compare_video_recordings = subprocess.Popen(compare_cmd, stdout=f) | 406 compare_video_recordings = subprocess.Popen(compare_cmd, stdout=f) |
| 407 compare_video_recordings.wait() | 407 compare_video_recordings.wait() |
| 408 print 'Result recorded to: ' + os.path.abspath(result_file_name) | 408 except OSError as e: |
| 409 print 'Comparison done!' | |
| 410 except subprocess.CalledProcessError as e: | |
| 411 print 'Something went wrong when trying to compare videos: ' + e | 409 print 'Something went wrong when trying to compare videos: ' + e |
| 412 raise | 410 raise |
| 411 else: | |
| 412 print 'Result recorded to: ' + os.path.abspath(result_file_name) | |
| 413 print 'Comparison done!' | |
| 413 | 414 |
| 415 def test(): | |
|
kjellander_webrtc
2017/03/14 21:20:07
Forgot to remove? :)
janssonWebRTC
2017/03/15 08:48:40
Done.
| |
| 416 print 'banan' | |
| 414 | 417 |
| 415 def main(): | 418 def main(): |
| 416 """The main function. | 419 """The main function. |
| 417 | 420 |
| 418 A simple invocation is: | 421 A simple invocation is: |
| 419 ./run_video_analysis.py \ | 422 ./run_video_analysis.py \ |
| 420 --app_name AppRTCMobile \ | 423 --app_name AppRTCMobile \ |
| 421 --ffmpeg ./ffmpeg --ref_video_device=/dev/video0 \ | 424 --ffmpeg ./ffmpeg --ref_video_device=/dev/video0 \ |
| 422 --test_video_device=/dev/video1 \ | 425 --test_video_device=/dev/video1 \ |
| 423 --zxing_path ./zxing \ | 426 --zxing_path ./zxing \ |
| 424 --test_crop_parameters 'crop=950:420:130:56' \ | 427 --test_crop_parameters 'crop=950:420:130:56' \ |
| 425 --ref_crop_parameters 'hflip, crop=950:420:130:56' \ | 428 --ref_crop_parameters 'hflip, crop=950:420:130:56' \ |
| 426 --ref_rec_dir /tmp/ref \ | 429 --ref_rec_dir /tmp/ref \ |
| 427 --test_rec_dir /tmp/test | 430 --test_rec_dir /tmp/test |
| 428 | 431 |
| 429 This will produce the following files if successful: | 432 This will produce the following files if successful: |
| 430 # Original video recordings. | 433 # Original video recordings. |
| 431 /tmp/ref/AppRTCMobile_<recording date and time>_ref.yuv | 434 /tmp/ref/AppRTCMobile_<recording date and time>_ref.yuv |
| 432 /tmp/test/AppRTCMobile_<recording date and time>_test.yuv | 435 /tmp/test/AppRTCMobile_<recording date and time>_test.yuv |
| 433 | 436 |
| 434 # Cropped video recordings according to the crop parameters. | 437 # Cropped video recordings according to the crop parameters. |
| 435 /tmp/ref/cropped_AppRTCMobile_<recording date and time>_ref.yuv | 438 /tmp/ref/cropped_AppRTCMobile_<recording date and time>_ref.yuv |
| 436 /tmp/test/cropped_AppRTCMobile_<recording date and time>_ref.yuv | 439 /tmp/test/cropped_AppRTCMobile_<recording date and time>_ref.yuv |
| 437 | 440 |
| 438 # Comparison metrics from cropped test and ref videos. | 441 # Comparison metrics from cropped test and ref videos. |
| 439 /tmp/test/AppRTCMobile_<recording date and time>_result.text | 442 /tmp/test/AppRTCMobile_<recording date and time>_result.text |
| 440 | 443 |
| 441 """ | 444 """ |
| 442 options = _ParseArgs() | 445 options = _ParseArgs() |
| 443 RestartMagewellDevices(options.ref_video_device, options.test_video_device) | 446 if not RestartMagewellDevices(options.ref_video_device, |
| 447 options.test_video_device): | |
| 448 return | |
| 449 | |
| 444 record_paths = CreateRecordingDirs(options) | 450 record_paths = CreateRecordingDirs(options) |
| 445 recording_result = StartRecording(options, record_paths) | 451 recording_result = StartRecording(options, record_paths['ref_rec_location'], |
| 452 record_paths['test_rec_location']) | |
| 453 if not recording_result: | |
| 454 return | |
| 446 | 455 |
| 447 # Do not require compare_video.py script to run, no metrics will be generated. | 456 # Do not require compare_video.py script to run, no metrics will be generated. |
| 448 if options.compare_videos_script: | 457 if options.compare_videos_script: |
| 449 CompareVideos(options, recording_result) | 458 CompareVideos(options, recording_result) |
| 450 else: | 459 else: |
| 451 print ('Skipping compare videos step due to compare_videos flag were not ' | 460 print ('Skipping compare videos step due to compare_videos flag were not ' |
| 452 'passed.') | 461 'passed.') |
| 453 | 462 |
| 454 | 463 |
| 455 if __name__ == '__main__': | 464 if __name__ == '__main__': |
| 456 sys.exit(main()) | 465 sys.exit(main()) |
| OLD | NEW |