def test_convert(self, ecmd): input, profile = "some-film.mkv", profiles.ROKU # Convert h264 with 16 refs stream = {"index": 0, "codec_type": "video", "codec_name": "h264", "refs": 16, "level": 51, "height": 720} processor = VideoProcessor(input, stream, profile) processor.convert() cmd = [ "ffmpeg", "-i", "some-film.mkv", "-map", "0:0", "-c:v", "h264", "-preset", "slow", "-crf", "22", "-profile:v", "high", "-level", "4.1", "video-0.mp4", ] self.assertTrue(ecmd.called) ecmd.assert_called_once_with(cmd)
def test_process(self): input, profile = "some-film.mkv", profiles.ROKU # Attempt process for 720:8 refs, nothing to do stream = {"index": 7, "codec_type": "video", "codec_name": "h264", "refs": 8, "height": 720} processor = VideoProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "some-film.mkv", "index": 7}) self.assertFalse(processor.convert.called) self.assertFalse(processor.clean_up.called) # Attempt process for 1080:8 refs, needs to convert stream = {"index": 7, "codec_type": "video", "codec_name": "h264", "refs": 8, "height": 1080} processor = VideoProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "video-7.mp4", "index": 0}) self.assertTrue(processor.convert.called) self.assertTrue(processor.clean_up.called) processor.convert.reset_mock() processor.clean_up.reset_mock() # Attempt to process 704:8, nothing to do stream = {"index": 7, "codec_type": "video", "codec_name": "h264", "refs": 8, "height": 704} processor = VideoProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "some-film.mkv", "index": 7}) self.assertFalse(processor.convert.called) self.assertFalse(processor.clean_up.called) # Attempt process for 2160:8 refs, needs to convert (default ref is 4) stream = {"index": 7, "codec_type": "video", "codec_name": "h264", "refs": 8, "height": 2160} processor = VideoProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "video-7.mp4", "index": 0}) self.assertTrue(processor.convert.called) self.assertTrue(processor.clean_up.called) processor.convert.reset_mock() processor.clean_up.reset_mock() # Attempt to process xvid, turn to h264 stream = {"index": 7, "codec_type": "video", "codec_name": "xvid", "refs": 1, "height": 720} processor = VideoProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "video-7.mp4", "index": 0}) self.assertTrue(processor.convert.called) self.assertTrue(processor.clean_up.called)