示例#1
0
 def test_get_middle_frame_even(self):
     """
     Tests calculate the middle frame when the video frame count is even.
     """
     try:
         video = Video(self.video_blob_path)
         middle_frame = video.get_middle_frame()
     finally:
         self.assertEqual(middle_frame, 125)
示例#2
0
 def test_get_from_to_frames_from_odd_max_frames(self):
     """
     Tests calculate the first and last frame to extracts when the max frames is odd.
     """
     try:
         video = Video(self.video_blob_path)
         middle_frame = video.get_middle_frame()
         from_frame, to_frame = video.get_from_to_frames(middle_frame, 11)
     finally:
         self.assertEqual(middle_frame, 125)
         self.assertEqual(from_frame, 120)
         self.assertEqual(to_frame, 130)
示例#3
0
    def convert_video(input_file, input_desc):
        """
        Convert video
        """
        modifications = []
        video = Video(input_file)
        as_frames = input_desc.get('as_frames', None)
        max_frames = int(evaluate(input_desc.get('max_frames')))
        max_pixels = int(evaluate(input_desc.get('max_pixels')))
        if as_frames:
            code = video.extract_frames(max_frames=max_frames,
                                        max_pixels=max_pixels)
            modifications.append('extracted to frames')
        else:
            code = video.create_avi(max_frames=max_frames,
                                    max_pixels=max_pixels)
            modifications.append('AVI created')
            modifications.append('huffman encoded')

        return code, modifications
示例#4
0
    def test_get_middle_frame_odd(self):
        """
        Tests calculate the middle frame when the video frame count is odd.
        """
        try:
            work_dir = os.path.split(self.video_blob_path)[0]
            input_desc = [{
                'description': 'input',
                'max_pixels': '150 * 100',
                'type': 'video',
                'max_weight': 5242880,
                'max_frames': 11
            }]
            response = self.convert(work_dir, input_desc, None)
            status = response.get('status')

            video = Video(
                os.path.split(self.video_blob_path)[0] + '/input_0.avi')
            middle_frame = video.get_middle_frame()
        finally:
            self.assertEqual(status, 'OK')
            self.assertEqual(middle_frame, 5)
            os.remove(os.path.split(self.video_blob_path)[0] + '/input_0.avi')