Made video quality toolchain more configurable.
R=kjellander@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/4139007
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5171 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/tools/compare_videos.py b/webrtc/tools/compare_videos.py
index ee8e6d5..f6275a6 100755
--- a/webrtc/tools/compare_videos.py
+++ b/webrtc/tools/compare_videos.py
@@ -9,8 +9,10 @@
import optparse
import os
+import shutil
import subprocess
import sys
+import tempfile
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
@@ -24,7 +26,7 @@
usage = 'usage: %prog [options]'
parser = optparse.OptionParser(usage=usage)
- parser.add_option('--label', type='string', default="MY_TEST",
+ parser.add_option('--label', type='string', default='MY_TEST',
help=('Label of the test, used to identify different '
'tests. Default: %default'))
parser.add_option('--ref_video', type='string',
@@ -34,6 +36,18 @@
'video (YUV).'))
parser.add_option('--frame_analyzer', type='string',
help='Path to the frame analyzer executable.')
+ parser.add_option('--barcode_decoder', type='string',
+ help=('Path to the barcode decoder script. By default, we '
+ 'will assume we can find it in barcode_tools/'
+ 'relative to this directory.'))
+ parser.add_option('--ffmpeg_path', type='string',
+ help=('The path to where the ffmpeg executable is located. '
+ 'If omitted, it will be assumed to be present in the '
+ 'PATH with the name ffmpeg[.exe].'))
+ parser.add_option('--zxing_path', type='string',
+ help=('The path to where the zxing executable is located. '
+ 'If omitted, it will be assumed to be present in the '
+ 'PATH with the name zxing[.exe].'))
parser.add_option('--stats_file', type='string', default='stats.txt',
help=('Path to the temporary stats file to be created and '
'used. Default: %default'))
@@ -77,14 +91,18 @@
"""
options = _ParseArgs()
- # Run barcode decoder on the test video to identify frame numbers.
- path_to_decoder = os.path.join(SCRIPT_DIR, 'barcode_tools',
- 'barcode_decoder.py')
+ if options.barcode_decoder:
+ path_to_decoder = options.barcode_decoder
+ else:
+ path_to_decoder = os.path.join(SCRIPT_DIR, 'barcode_tools',
+ 'barcode_decoder.py')
# On Windows, sometimes the inherited stdin handle from the parent process
# fails. Work around this by passing null to stdin to the subprocesses.
null_filehandle = open(os.devnull, 'r')
+ # Run barcode decoder on the test video to identify frame numbers.
+ png_working_directory = tempfile.mkdtemp()
cmd = [
sys.executable,
path_to_decoder,
@@ -92,10 +110,17 @@
'--yuv_frame_width=%d' % options.yuv_frame_width,
'--yuv_frame_height=%d' % options.yuv_frame_height,
'--stats_file=%s' % options.stats_file,
+ '--png_working_dir=%s' % png_working_directory,
]
+ if options.zxing_path:
+ cmd.append('--zxing_path=%s' % options.zxing_path)
+ if options.ffmpeg_path:
+ cmd.append('--ffmpeg_path=%s' % options.ffmpeg_path)
barcode_decoder = subprocess.Popen(cmd, stdin=null_filehandle,
stdout=sys.stdout, stderr=sys.stderr)
barcode_decoder.wait()
+
+ shutil.rmtree(png_working_directory)
if barcode_decoder.returncode != 0:
print 'Failed to run barcode decoder script.'
return 1