1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
9 from telemetry import benchmark
10 from telemetry.core import bitmap
11 from telemetry.core import platform
12 from telemetry.core import util
13 from telemetry.core import video
16 class VideoTest(unittest.TestCase) :
19 def testFramesFromMp4(self):
20 host_platform = platform.GetHostPlatform()
23 host_platform.InstallApplication('avconv')
25 if not host_platform.CanLaunchApplication('avconv'):
26 logging.warning('Test not supported on this platform')
27 return # pylint: disable=W0150
29 vid = os.path.join(util.GetUnittestDataDir(), 'vid.mp4')
30 expected_timestamps = [
41 video_obj = video.Video(vid)
43 # Calling _FramesFromMp4 should return all frames.
44 # pylint: disable=W0212
45 for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4(vid)):
46 timestamp, bmp = timestamp_bitmap
47 self.assertEquals(timestamp, expected_timestamps[i])
48 expected_bitmap = bitmap.Bitmap.FromPngFile(os.path.join(
49 util.GetUnittestDataDir(), 'frame%d.png' % i))
50 self.assertTrue(expected_bitmap.IsEqual(bmp))