class_docstr: MP3 encoder based on Gstreamer
class_docstr_tok: ["MP3","encoder","based","on","Gstreamer"]
code: def setup(
      self,
      channels=None,
      samplerate=None,
      blocksize=None,
      totalframes=None,
  ):
      super(Mp3Encoder, self).setup(
          channels, samplerate, blocksize, totalframes
      )
  
      # http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-ugly-plugins/html/gst-plugins-ugly-plugins-lamemp3enc.html#GstLameMP3Enc--cbr
      # cbr only makes sense when target is equal to `bitrate`
      str_cbr = " cbr=%s" % self.cbr if self.target == "bitrate" else ""
      self.pipe = """appsrc name=src
                    ! audioconvert ! audioresample
                    ! lamemp3enc target=%(target)s %(target)s=%(target_value)d%(str_cbr)s encoding-engine-quality=standard
                    ! xingmux
                    ! id3v2mux
                    """ % {
          "target": self.target,
          "target_value": self.target_value,
          "str_cbr": str_cbr,
      }
  
      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.start_pipeline(channels, samplerate)
  
file_path: TimeSide/timeside/plugins/encoder/mp3.py
imports: from timeside.core import implements, interfacedoc
  from timeside.core.encoder import GstEncoder
  from timeside.core.api import IEncoder
label_desc: Use image node_id 2 for calling the Mp3Encoder obj's underlying member method code with example usage: obj.setup(channels, samplerate, blocksize, totalframes) without return types