Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Bug 928115 - Actually support higher fps modes in get-metric-for-buil…
Browse files Browse the repository at this point in the history
…d;r=davehunt

Not quite yet working for the dashboard yet, but I thought it would be good to
get something basic going so we can start comparing results, etc.
  • Loading branch information
wlach committed Nov 12, 2013
1 parent f7eeb32 commit e3a50af
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions bin/get-metric-for-build.py
Expand Up @@ -58,6 +58,7 @@ def runtest(device_prefs, testname, options, apk=None, appname = None,
profile_file=profile_file,
capture_area=options.capture_area,
no_capture=options.no_capture,
fps=options.fps,
capture_file=capture_file,
sync_time=options.sync_time)

Expand Down
5 changes: 3 additions & 2 deletions src/eideticker/eideticker/runtest.py
Expand Up @@ -16,7 +16,7 @@ def run_test(testkey, capture_device, appname, capture_name,
request_log_file=None, actions_log_file=None,
log_checkerboard_stats=False, extra_env_vars={},
capture_area=None, no_capture=False, capture_file=None,
sync_time=True):
sync_time=True, fps=None):
testinfo = get_testinfo(testkey)
print "Testinfo: %s" % testinfo

Expand Down Expand Up @@ -87,7 +87,8 @@ def run_test(testkey, capture_device, appname, capture_name,
testpath_rel += "?%s" % urllib.quote_plus(testinfo.get('urlParams'))

capture_controller = videocapture.CaptureController(capture_device, capture_area,
custom_tempdir=EIDETICKER_TEMP_DIR)
custom_tempdir=EIDETICKER_TEMP_DIR,
fps=fps)

testtype = test_type or testinfo['type']

Expand Down
2 changes: 1 addition & 1 deletion src/videocapture/videocapture/capture.py
Expand Up @@ -49,7 +49,7 @@ def __init__(self, filename):

@property
def fps(self):
return 60.0
return self.metadata.get('fps', 60.0)

@property
def length(self):
Expand Down
28 changes: 20 additions & 8 deletions src/videocapture/videocapture/controller.py
Expand Up @@ -45,7 +45,7 @@ class CaptureProcess(multiprocessing.Process):

def __init__(self, capture_device, video_format, frame_counter,
finished_semaphore, output_raw_filename=None,
outputdir=None):
outputdir=None, fps=None):
multiprocessing.Process.__init__(self, args=(frame_counter,
finished_semaphore,))
self.frame_counter = frame_counter
Expand All @@ -54,6 +54,7 @@ def __init__(self, capture_device, video_format, frame_counter,
self.capture_device = capture_device
self.video_format = video_format
self.finished_semaphore = finished_semaphore
self.fps = fps

def stop(self):
self.finished_semaphore.value = True
Expand All @@ -62,7 +63,7 @@ def run(self):
timeout = 10
if self.capture_device == "decklink":
mode = supported_formats[self.video_format]["decklink_mode"]
args = (os.path.join(DECKLINK_DIR, 'decklink-capture'),
args = [os.path.join(DECKLINK_DIR, 'decklink-capture'),
'-o',
'-m',
'%s' % mode,
Expand All @@ -71,21 +72,23 @@ def run(self):
'-n',
'6000',
'-f',
self.output_raw_filename)
self.output_raw_filename]
elif self.capture_device == "pointgrey":
# get the device type
camera_id = subprocess.check_output([os.path.join(POINTGREY_DIR, "get-camera-id")]).strip()
camera_config = camera_configs.get(camera_id)
if not camera_config:
raise Exception("No camera configuration for model '%s'" % camera_id)
args = (os.path.join(POINTGREY_DIR, 'pointgrey-capture'),
args = [os.path.join(POINTGREY_DIR, 'pointgrey-capture'),
'-c',
os.path.join(POINTGREY_DIR, camera_config),
'-o',
'-n',
'1200',
'-f',
self.outputdir)
self.outputdir]
if self.fps:
args.extend([ '-r', str(self.fps) ])
timeout = 300 # pointgrey devices need an extra long timeout
else:
raise Exception("Unknown capture device '%s'" % self.capture_device)
Expand Down Expand Up @@ -127,7 +130,7 @@ class CaptureController(object):

def __init__(self, capture_device, capture_area = None,
find_start_signal=True, find_end_signal=True,
custom_tempdir=None):
custom_tempdir=None, fps=None):
self.capture_process = None
self.null_read = file('/dev/null', 'r')
self.null_write = file('/dev/null', 'w')
Expand All @@ -141,6 +144,7 @@ def __init__(self, capture_device, capture_area = None,
self.capture_area = capture_area
self.find_start_signal = find_start_signal
self.find_end_signal = find_end_signal
self.fps = fps

def log(self, msg):
print "%s Capture Controller | %s" % (datetime.datetime.now().strftime("%b %d %H:%M:%S %Z"), msg)
Expand Down Expand Up @@ -170,7 +174,8 @@ def start_capture(self, output_filename, mode=None,
self.frame_counter,
self.finished_semaphore,
output_raw_filename=output_raw_filename,
outputdir=self.outputdir)
outputdir=self.outputdir,
fps=self.fps)
self.log("Starting capture...")
self.capture_process.start()
# wait for capture to actually start...
Expand Down Expand Up @@ -300,11 +305,17 @@ def _rewrite_frame(framenum, dirname, imagefilename):
for p in multiprocesses:
p.join()


capturefps = self.fps
if not capturefps:
capturefps = 60

if create_webm:
self.log("Creating movie ...")

moviefile = tempfile.NamedTemporaryFile(dir=self.custom_tempdir,
suffix=".webm")
subprocess.Popen(('ffmpeg', '-y', '-r', '60', '-i',
subprocess.Popen(('ffmpeg', '-y', '-r', str(capturefps), '-i',
os.path.join(rewritten_imagedir, '%d.png'),
moviefile.name), close_fds=True).wait()

Expand All @@ -315,6 +326,7 @@ def _rewrite_frame(framenum, dirname, imagefilename):
json.dumps(dict({ 'captureDevice': self.capture_device,
'date': self.capture_time.isoformat(),
'frameDimensions': frame_dimensions,
'fps': capturefps,
'version': 1 },
**self.capture_metadata)))

Expand Down
2 changes: 1 addition & 1 deletion src/videocapture/videocapture/framediff.py
Expand Up @@ -139,4 +139,4 @@ def get_stable_frame(capture, method='framediff', threshold=4096):
return len(entropy_diffs)-1

def get_stable_frame_time(capture, method='framediff', threshold = 4096):
return get_stable_frame(capture, method=method, threshold=threshold) / 60.0
return get_stable_frame(capture, method=method, threshold=threshold) / float(capture.fps)
4 changes: 4 additions & 0 deletions src/videocapture/videocapture/options.py
Expand Up @@ -20,6 +20,10 @@ def _add_options(self):
type = "string", dest = "mode",
default = None,
help = "mode to use with decklink cards (%s)" % " or ".join(valid_decklink_modes))
self.add_option("--fps", action="store", type="int", dest="fps",
help="Custom fps value to use (certain pointgrey "
"cameras only)", default=None)

if self.capture_area_option:
self.add_option("--capture-area", action="store",
default=os.environ.get('CAPTURE_AREA', None),
Expand Down
1 change: 1 addition & 0 deletions src/videocapture/videocapture/pointgrey/Capture.cpp
Expand Up @@ -32,6 +32,7 @@ int usage(char *progname, int status)
"\n"
" -d Output debugging information\n"
" -o If specified, print frame numbers while capturing\n"
" -r Frames per second (default is 60)\n"
" -f <outputdir> Directory video files will be written to\n"
" -c <configfile> Configuration file for camera (in JSON format)\n"
" -n <frames> Max number of frames to capture (default is 20 * framerate)\n"
Expand Down

0 comments on commit e3a50af

Please sign in to comment.