def tearDown(self): uri = get_uri(self.source) uri_info = get_media_uri_info(uri) if self.test_exact_duration: self.assertEqual(self.source_duration, uri_info['duration']) else: self.assertAlmostEqual(self.source_duration, uri_info['duration'], places=1) self.assertEqual(self.expected_channels, uri_info['streams'][0]['channels']) self.assertEqual(self.expected_samplerate, uri_info['streams'][0]['samplerate']) self.assertEqual(self.expected_depth, uri_info['streams'][0]['depth'])
def __init__(self, uri, start=0, duration=None, stack=False, sha1=None): super(FileDecoder, self).__init__(start=start, duration=duration) self.from_stack = False self.stack = stack self.uri = get_uri(uri).encode('utf8') if not sha1: self._sha1 = get_sha1(uri) else: self._sha1 = sha1.encode('utf8') self.uri_total_duration = get_media_uri_info(self.uri)['duration'] self.mimetype = None
def tearDown(self): # Source through ArrayDecoder decoder = ArrayDecoder(self.generate_source(), samplerate=self.samplerate) # Encoder if not hasattr(self, 'sink'): file_extension = '.' + self.encoder_function.file_extension() self.sink = tmp_file_sink(prefix=self.__class__.__name__, suffix=file_extension) if not hasattr(self, 'encoder'): self.encoder = self.encoder_function(self.sink, overwrite=self.overwrite) # Run Pipe (decoder | self.encoder).run() if self.encode_to_file: media_info = get_media_uri_info(get_uri(self.sink)) media_duration = media_info['duration'] media_channels = media_info['streams'][0]['channels'] media_samplerate = media_info['streams'][0]['samplerate'] os.unlink(self.sink) if self.test_duration: self.assertAlmostEqual(self.source_duration, media_duration, delta=self.delta) if self.test_channels: self.assertEqual(self.channels, media_channels) else: self.assertEqual(2, media_channels) # voaacenc bug ? self.assertEqual(media_samplerate, self.samplerate) if 0: import commands print commands.getoutput('sndfile-info ' + self.sink) self.assertEqual(self.expected_total_frames, self.encoder.num_samples) self.assertEqual(self.channels, self.encoder.channels()) self.assertEqual(self.samplerate, self.encoder.samplerate()) self.assertEqual(self.source_duration, self.encoder.num_samples/self.encoder.samplerate())
def tearDown(self): self.assertEqual(self.uri, get_uri(self.source))