gmyth-stream/server/0.2/plugins/transcoders/gstreamer.py
branchtrunk
changeset 590 1c421f2531d3
parent 573 f4927ca53da7
     1.1 --- a/gmyth-stream/server/0.2/plugins/transcoders/gstreamer.py	Thu Apr 19 16:14:41 2007 +0100
     1.2 +++ b/gmyth-stream/server/0.2/plugins/transcoders/gstreamer.py	Tue Apr 24 00:43:20 2007 +0100
     1.3 @@ -30,11 +30,7 @@
     1.4              self.Vbin = vbin
     1.5              self.Sink = sink
     1.6              self.Loop = gobject.MainLoop()
     1.7 -            self.ACaps = ""
     1.8 -            self.VCaps = ""
     1.9              self.Ready = False
    1.10 -            self.Connection = None
    1.11 -            self.Addr = None
    1.12          # __init__()
    1.13  
    1.14      # StreamData()
    1.15 @@ -47,13 +43,12 @@
    1.16          self.connection = None
    1.17          self.addr = None
    1.18          self.ready = False
    1.19 -
    1.20 -        self.log.info("Params for Gstreamer: %s" % self.params)
    1.21 +        self.log.debug("Params for Gstreamer: %s" % self.params)
    1.22      # __init__()
    1.23  
    1.24  
    1.25      def _create_start_elements(self, uri):
    1.26 -        self.log.info("Opening Uri:" + uri)
    1.27 +        self.log.debug("Opening Uri:" + uri)
    1.28          src = gst.element_make_from_uri(gst.URI_SRC, uri, "src")
    1.29          decode = gst.element_factory_make("decodebin", "decode")
    1.30          mux = gst.element_factory_make("ffmux_mpeg", "mux")
    1.31 @@ -76,18 +71,18 @@
    1.32          vencode.set_property ("quantizer", 5)
    1.33  
    1.34          if None in [vbin, vqueue, vrate, vencode, vqueue_src]:
    1.35 -            self.log.info("Fail to create video encode elements.")
    1.36 +            self.log.error("Fail to create video encode elements.")
    1.37              return False
    1.38  
    1.39          vbin.add(vqueue)
    1.40          if int(width) > 0 and int(height) > 0:
    1.41 -            self.log.info(("Formating output to %d / %d" %(int(width), int(height))))
    1.42 +            self.log.debug("Formating output to %d / %d" % ( int(width), int(height)))
    1.43  
    1.44              vscale = gst.element_factory_make("ffvideoscale", "vscale")
    1.45  
    1.46              vbin.add(vscale);
    1.47              if not vqueue.link(vscale):
    1.48 -                self.log.info("Fail to link video elements")
    1.49 +                self.log.error("Fail to link video elements")
    1.50                  return False
    1.51  
    1.52              vbin.add(colorspace)
    1.53 @@ -95,7 +90,7 @@
    1.54              if not vscale.link(colorspace, \
    1.55                  gst.caps_from_string("video/x-raw-yuv,width=(int)%d,height=(int)%d" %(\
    1.56                  int(width), int(height)))):
    1.57 -                self.log.info("Fail to link video elements")
    1.58 +                self.log.error("Fail to link video elements")
    1.59                  return False
    1.60          else:
    1.61              vbin.add(colorspace)
    1.62 @@ -103,16 +98,16 @@
    1.63  
    1.64          vbin.add(vrate, vencode, vqueue_src)
    1.65          if not colorspace.link(vrate):
    1.66 -            self.log.info("Fail to colorspace with vrate")
    1.67 +            self.log.error("Fail to colorspace with vrate")
    1.68              return False
    1.69  
    1.70          if not vrate.link(vencode, \
    1.71              gst.caps_from_string("video/x-raw-yuv,framerate=(fraction)10/1")):
    1.72 -            self.log.info("Fail to link vrate element")
    1.73 +            self.log.error("Fail to link vrate element")
    1.74              return False
    1.75  
    1.76          if not vencode.link(vqueue_src):
    1.77 -            self.log.info("Fail to link video encode with queue")
    1.78 +            self.log.error("Fail to link video encode with queue")
    1.79              return False
    1.80  
    1.81          vbin.add_pad(gst.GhostPad("sink", vqueue.get_pad("sink")))
    1.82 @@ -129,32 +124,32 @@
    1.83          #aencode = gst.element_factory_make("ffenc_mp2", "aencode")
    1.84          aencode = gst.element_factory_make("lame", "aencode")
    1.85          aqueue_src = gst.element_factory_make("queue", "aqueue_src")
    1.86 -       
    1.87 +
    1.88          if None in [abin, aqueue, aencode, aqueue_src]:
    1.89 -            self.log.info("Fail to create video encode elements.")
    1.90 +            self.log.error("Fail to create video encode elements.")
    1.91              return False
    1.92  
    1.93 -        #aencode.set_property ("bitrate", 32)            
    1.94 +        #aencode.set_property ("bitrate", 32)
    1.95          #aencode.set_property ("vbr-quality", 2)
    1.96  
    1.97          abin.add(aqueue, aconvert, aencode, aqueue_src)
    1.98  
    1.99 -        self.log.info ("Link queue -> aconvert")
   1.100 +        self.log.debug("Link queue -> aconvert")
   1.101          if not aqueue.link (aconvert):
   1.102 -            self.log.info("Fail to link queue video")
   1.103 +            self.log.error("Fail to link queue video")
   1.104              return False
   1.105  
   1.106 -        self.log.info ("Link aconvert -> aencode")
   1.107 +        self.log.debug("Link aconvert -> aencode")
   1.108          if not aconvert.link (aencode):
   1.109 -            self.log.info("Fail to link video elements")
   1.110 +            self.log.error("Fail to link video elements")
   1.111              return False
   1.112  
   1.113 -        self.log.info ("Link aencode -> aqueue_src")
   1.114 +        self.log.debug("Link aencode -> aqueue_src")
   1.115          if not aencode.link (aqueue_src):
   1.116 -            self.log.info("Fail to link aencode -> aqueue_src")
   1.117 +            self.log.error("Fail to link aencode -> aqueue_src")
   1.118              return False
   1.119  
   1.120 -        self.log.info ("Link:OK")
   1.121 +        self.log.debug("Link:OK")
   1.122  
   1.123          ghost_sink = gst.GhostPad("sink", aqueue.get_pad("sink"))
   1.124          ghost_src = gst.GhostPad("src", aqueue_src.get_pad("src"))
   1.125 @@ -207,11 +202,11 @@
   1.126          video_pad = vbin.get_pad("src")
   1.127  
   1.128          if audio_pad.link(mux_audio) != gst.PAD_LINK_OK:
   1.129 -            self.log.info("Fail to link audio with mux")
   1.130 +            self.log.error("Fail to link audio with mux")
   1.131              return False
   1.132  
   1.133          if video_pad.link(mux_video) != gst.PAD_LINK_OK:
   1.134 -            self.log.info("Fail to link audio with mux")
   1.135 +            self.log.error("Fail to link audio with mux")
   1.136              return False
   1.137  
   1.138          self.stream_data = self.StreamData(self.log, pipe, abin, vbin, sink)
   1.139 @@ -231,7 +226,7 @@
   1.140      def __on_bus_message(self, bus, message, stream_data):
   1.141  
   1.142          t = message.type
   1.143 -        self.log.info ("__on_bus_message")
   1.144 +        self.log.debug("__on_bus_message")
   1.145  
   1.146          if t == gst.MESSAGE_STATE_CHANGED:
   1.147              oldstate = -1
   1.148 @@ -278,20 +273,20 @@
   1.149      def __on_decode_new_pad(self, decode, pad, arg1, stream_data):
   1.150  
   1.151          caps = pad.get_caps().to_string()
   1.152 -        self.log.info("New pad " + caps)
   1.153 +        self.log.debug("New pad " + caps)
   1.154          if caps.rfind("audio") != -1:
   1.155              apad = stream_data.Abin.get_pad("sink")
   1.156              if pad.link(apad) != gst.PAD_LINK_OK:
   1.157 -                self.log.info("Error on link audio pad")
   1.158 +                self.log.error("Error on link audio pad")
   1.159                  return None
   1.160          elif caps.rfind("video") != -1:
   1.161              vpad = stream_data.Vbin.get_pad("sink")
   1.162              if pad.link(vpad) != gst.PAD_LINK_OK:
   1.163 -                self.log.info("Error on link video pad")
   1.164 +                self.log.error("Error on link video pad")
   1.165                  return None
   1.166          else:
   1.167 -            self.log.info("Invalid caps")
   1.168 -        self.log.info("Linked")
   1.169 +            self.log.error("Invalid caps")
   1.170 +        self.log.debug("Linked")
   1.171      # __on_decode_new_pad
   1.172  
   1.173  
   1.174 @@ -305,15 +300,13 @@
   1.175                     params_first("abitrate", 192000),  params_first("width", 320),
   1.176                     params_first("height", 240), params_first("options", ""))
   1.177  
   1.178 -        self.log.info("Play %s", outfd.fileno())
   1.179 +        self.log.debug("Play %s", outfd.fileno())
   1.180          self.stream_data.Sink.set_property("fd", outfd.fileno())
   1.181          self.log.info("Setting Pipeline state to PLAYING")
   1.182          self.stream_data.Pipe.set_state(gst.STATE_PLAYING)
   1.183  
   1.184          # keep playing until EOS
   1.185          self.stream_data.Loop.run()
   1.186 -        self.log.info("quit loop")
   1.187 -
   1.188          return True
   1.189      # start()
   1.190