]> git.parisson.com Git - timeside.git/commitdiff
add totalframes
authoryomguy <yomguy@parisson.com>
Wed, 26 Sep 2012 20:17:00 +0000 (22:17 +0200)
committeryomguy <yomguy@parisson.com>
Wed, 26 Sep 2012 20:17:00 +0000 (22:17 +0200)
timeside/encoder/mp3.py

index c1455e47ca62697f522dfa7ada14bac6c382cc57..a5ead73ee507658aa94c461bca056b4539578c68 100644 (file)
@@ -40,46 +40,46 @@ class Mp3Encoder(Processor):
         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, nframes=None):
+    def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
         self.channels = channels
-        super(Mp3Encoder, self).setup(channels, samplerate, nframes)
+        super(Mp3Encoder, self).setup(channels, samplerate, blocksize, totalframes)
         #TODO: open file for writing
-        # the output data format we want        
+        # the output data format we want
         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
             ! queue ! filesink location=%s
             t. ! queue ! appsink name=app sync=False
             ''' % self.filename
-            
+
         elif self.filename :
             self.pipe += '! filesink location=%s async=False sync=False ' % self.filename
         else:
             self.pipe += '! queue ! appsink name=app sync=False '
-            
+
         self.pipeline = gst.parse_launch(self.pipe)
         # store a pointer to appsrc in our encoder object
         self.src = self.pipeline.get_by_name('src')
         # store a pointer to appsink in our encoder object
         self.app = self.pipeline.get_by_name('app')
-        
+
         srccaps = gst.Caps("""audio/x-raw-float,
             endianness=(int)1234,
             channels=(int)%s,
             width=(int)32,
             rate=(int)%d""" % (int(channels), int(samplerate)))
         self.src.set_property("caps", srccaps)
-        
+
         self.pipeline.set_state(gst.STATE_PLAYING)
-    
+
     @staticmethod
     @interfacedoc
     def id():
@@ -108,7 +108,7 @@ class Mp3Encoder(Processor):
     @interfacedoc
     def set_metadata(self, metadata):
         self.metadata = metadata
-  
+
     def write_metadata(self):
         """Write all ID3v2.4 tags to file from self.metadata"""
         from mutagen import id3
@@ -124,7 +124,7 @@ class Mp3Encoder(Processor):
             id3.save()
         except:
             raise IOError('EncoderError: cannot write tags')
-    
+
     @interfacedoc
     def process(self, frames, eod=False):
         self.eod = eod
@@ -135,12 +135,12 @@ class Mp3Encoder(Processor):
         if self.eod and self.metadata and self.filename:
             self.write_metadata()
         return frames, eod
-        
+
 class Mp3EncoderSubprocess(object):
     """MP3 encoder in a subprocess pipe"""
 
 #    implements(IEncoder)
-    
+
     def __init__(self):
         import os
         import string
@@ -162,12 +162,12 @@ class Mp3EncoderSubprocess(object):
                              'publisher': 'tc', #comment
                              'date': 'ty', #year
                              }
-    
+
     @interfacedoc
     def setup(self, channels=None, samplerate=None, nframes=None):
         self.channels = channels
         super(Mp3EncoderSubprocess, self).setup(channels, samplerate, nframes)
-        
+
     @staticmethod
     @interfacedoc
     def id():
@@ -196,7 +196,7 @@ class Mp3EncoderSubprocess(object):
     @interfacedoc
     def set_metadata(self, metadata):
         self.metadata = metadata
-  
+
     def get_file_info(self):
         try:
             file_out1, file_out2 = os.popen4('mp3info "'+self.dest+'"')