def StopVideoCapture(self):
        assert self.is_video_capture_running, 'Must start video capture first'
        self._video_recorder.Stop()
        self._video_recorder.Pull()
        self._video_recorder = None

        return video.Video(self, self._video_output)
Ejemplo n.º 2
0
  def testFramesFromMp4(self):
    host_platform = platform.GetHostPlatform()

    try:
      host_platform.InstallApplication('avconv')
    finally:
      if not host_platform.CanLaunchApplication('avconv'):
        logging.warning('Test not supported on this platform')
        return  # pylint: disable=W0150

    vid = os.path.join(util.GetUnittestDataDir(), 'vid.mp4')
    expected_timestamps = [
      0,
      763,
      783,
      940,
      1715,
      1732,
      1842,
      1926,
      ]

    video_obj = video.Video(vid)

    # Calling _FramesFromMp4 should return all frames.
    # pylint: disable=W0212
    for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4(vid)):
      timestamp, bmp = timestamp_bitmap
      self.assertEquals(timestamp, expected_timestamps[i])
      expected_bitmap = image_util.FromPngFile(os.path.join(
          util.GetUnittestDataDir(), 'frame%d.png' % i))
      self.assertTrue(image_util.AreEqual(expected_bitmap, bmp))
Ejemplo n.º 3
0
    def testFramesFromMp4(self):
        mock_adb = MockDevice(MockAdbCommands())
        backend = android_platform_backend.AndroidPlatformBackend(
            mock_adb, False)

        try:
            backend.InstallApplication('avconv')
        finally:
            if not backend.CanLaunchApplication('avconv'):
                logging.warning('Test not supported on this platform')
                return  # pylint: disable=W0150

        vid = os.path.join(util.GetUnittestDataDir(), 'vid.mp4')
        expected_timestamps = [
            0,
            763,
            783,
            940,
            1715,
            1732,
            1842,
            1926,
        ]

        video_obj = video.Video(backend, vid)

        # Calling _FramesFromMp4 should return all frames.
        # pylint: disable=W0212
        for i, timestamp_bitmap in enumerate(video_obj._FramesFromMp4(vid)):
            timestamp, bmp = timestamp_bitmap
            self.assertEquals(timestamp, expected_timestamps[i])
            expected_bitmap = bitmap.Bitmap.FromPngFile(
                os.path.join(util.GetUnittestDataDir(), 'frame%d.png' % i))
            self.assertTrue(expected_bitmap.IsEqual(bmp))
    def StopVideoCapture(self):
        assert self.is_video_capture_running, 'Must start video capture first'
        self._video_recorder.Stop()
        video_file_obj = tempfile.NamedTemporaryFile()
        self._video_recorder.Pull(video_file_obj.name)
        self._video_recorder = None

        return video.Video(video_file_obj)
Ejemplo n.º 5
0
 def StopVideoCapture(self):
     self._is_video_capture_running = False
     return video.Video(tempfile.NamedTemporaryFile())
Ejemplo n.º 6
0
 def StopVideoCapture(self):
     self._is_video_capture_running = False
     return video.Video(self, None)