From: Paul Brossier Date: Thu, 27 Sep 2012 15:39:58 +0000 (-0600) Subject: timeside/encoder/mp3.py: merge with origin X-Git-Tag: 0.4.0^2~5^2 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c7020f1e0032107f1177cf2f129062f9c715b368;p=timeside.git timeside/encoder/mp3.py: merge with origin --- c7020f1e0032107f1177cf2f129062f9c715b368 diff --cc timeside/encoder/mp3.py index f100b5b,a5ead73..c59cc57 --- a/timeside/encoder/mp3.py +++ b/timeside/encoder/mp3.py @@@ -40,17 -40,19 +40,17 @@@ class Mp3Encoder(GstEncoder) self.streaming = streaming if not self.filename and not self.streaming: raise Exception('Must give an output') - + self.metadata = None self.eod = False - + @interfacedoc - def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None): - self.channels = channels - super(Mp3Encoder, self).setup(channels, samplerate, blocksize, totalframes) - #TODO: open file for writing - # the output data format we want + def setup(self, channels=None, samplerate=None, nframes=None): + super(Mp3Encoder, self).setup(channels, samplerate, nframes) + self.pipe = '''appsrc name=src - ! audioconvert - ! lamemp3enc target=quality quality=2 encoding-engine-quality=standard ! id3v2mux + ! audioconvert + ! lamemp3enc target=quality quality=2 encoding-engine-quality=standard ! id3v2mux ''' if self.filename and self.streaming: self.pipe += ''' ! tee name=t @@@ -109,7 -124,18 +109,7 @@@ id3.save() except: raise IOError('EncoderError: cannot write tags') - + - @interfacedoc - def process(self, frames, eod=False): - self.eod = eod - buf = numpy_array_to_gst_buffer(frames) - self.src.emit('push-buffer', buf) - if self.streaming: - self.chunk = self.app.emit('pull-buffer') - if self.eod and self.metadata and self.filename: - self.write_metadata() - return frames, eod - class Mp3EncoderSubprocess(object): """MP3 encoder in a subprocess pipe"""