def test_convert(self, ecmd): input, profile = "some-film.mkv", profiles.ROKU # Convert flac with 6 channels stream = {"index": 1, "codec_type": "audio", "codec_name": "flac", "channels": 6, "tags": {"language": "por"}} processor = AudioProcessor(input, stream, profile) processor.convert() cmd = ["ffmpeg", "-i", "some-film.mkv", "-map", "0:1", "-c:a", "mp3", "-q:a", "2", "-ac:0", "2", "audio-1.mp3"] self.assertTrue(ecmd.called) ecmd.assert_called_once_with(cmd)
def test_process(self): input, profile = "some-film.mkv", profiles.ROKU # Attempt simple process, nothing to do stream = {"index": 1, "codec_type": "audio", "codec_name": "aac", "channels": 2, "tags": {"language": "por"}} processor = AudioProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "some-film.mkv", "index": 1, "language": "por"}) self.assertFalse(processor.convert.called) self.assertFalse(processor.clean_up.called) # Attempt process with less channels, should do nothing stream = {"index": 1, "codec_type": "audio", "codec_name": "aac", "channels": 1, "tags": {"language": "por"}} processor = AudioProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "some-film.mkv", "index": 1, "language": "por"}) self.assertFalse(processor.convert.called) self.assertFalse(processor.clean_up.called) # Attempt mp3 process, should convert stream = {"index": 1, "codec_type": "audio", "codec_name": "ac3", "channels": 2, "tags": {"language": "por"}} processor = AudioProcessor(input, stream, profile) res = processor.process() self.assertEqual(res, {"input": "audio-1.mp3", "index": 0, "language": "por"}) self.assertTrue(processor.convert.called) self.assertTrue(processor.clean_up.called)