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

Unified Diff: tools/telemetry/telemetry/core/video.py

Issue 756553003: [Telemetry] Fix video_unittest so that it actually runs on bots. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/video.py
diff --git a/tools/telemetry/telemetry/core/video.py b/tools/telemetry/telemetry/core/video.py
index 4eb4cab3bbcf3714d1e69d18644de58d5c24ecd2..c4211e4fe55712267657c6fe6d7a9c955fb353f2 100644
--- a/tools/telemetry/telemetry/core/video.py
+++ b/tools/telemetry/telemetry/core/video.py
@@ -18,9 +18,13 @@ class Video(object):
"""Utilities for storing and interacting with the video capture."""
def __init__(self, video_file_obj):
- assert video_file_obj.delete
- assert not video_file_obj.close_called
+ """Initializes the Video object.
+
+ args:
+ video_file: A file-like object."""
+ assert(hasattr(video_file_obj, 'name'))
self._video_file_obj = video_file_obj
+
self._tab_contents_bounding_box = None
def UploadToCloudStorage(self, bucket, target_path):
@@ -43,7 +47,7 @@ class Video(object):
time_ms is milliseconds since navigationStart.
bitmap is a telemetry.core.Bitmap.
"""
- frame_generator = self._FramesFromMp4(self._video_file_obj.name)
+ frame_generator = self._FramesFromMp4()
# Flip through frames until we find the initial tab contents flash.
content_box = None
@@ -113,7 +117,7 @@ class Video(object):
return self._tab_contents_bounding_box
- def _FramesFromMp4(self, mp4_file):
+ def _FramesFromMp4(self):
host_platform = platform.GetHostPlatform()
if not host_platform.CanLaunchApplication('avconv'):
host_platform.InstallApplication('avconv')
@@ -151,14 +155,15 @@ class Video(object):
if 'pts=' in line:
return int(1000 * float(line.split('=')[-1]))
- dimensions = GetDimensions(mp4_file)
+ dimensions = GetDimensions(self._video_file_obj.name)
frame_length = dimensions[0] * dimensions[1] * 3
frame_data = bytearray(frame_length)
# Use rawvideo so that we don't need any external library to parse frames.
- proc = subprocess.Popen(['avconv', '-i', mp4_file, '-vcodec',
- 'rawvideo', '-pix_fmt', 'rgb24', '-dump',
- '-loglevel', 'debug', '-f', 'rawvideo', '-'],
+ proc = subprocess.Popen(['avconv', '-i', self._video_file_obj.name,
+ '-vcodec', 'rawvideo', '-pix_fmt', 'rgb24',
+ '-dump', '-loglevel', 'debug', '-f', 'rawvideo',
+ '-'],
stderr=subprocess.PIPE, stdout=subprocess.PIPE)
while True:
num_read = proc.stdout.readinto(frame_data)
« no previous file with comments | « tools/telemetry/telemetry/core/platform/linux_platform_backend.py ('k') | tools/telemetry/telemetry/core/video_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698