Handle rtmpsinc send error

Bkmz zzbkmzz at gmail.com
Tue Dec 11 02:51:25 PST 2012


Hello, folks.

I have a python program that does live streaming via rtmpsinc


The code:

import pygst
pygst.require("0.10")

import gobject
gobject.threads_init()

import gst
import time

class Publisher:

   def __init__(self):

     self.pipeline = gst.parse_launch("appsrc min-latency=1000 
is-live=true do-timestamp=true name=source ! ffmpegcolorspace ! queue ! 
ffenc_flv ! flvmux ! rtmpsink location=\"rtmp://127.0.0.1/oflaDemo/test2 
live=1\" ")
     self.source = self.pipeline.get_by_name("source")

     self.caps = gst.Caps("video/x-raw-rgb, width=(int)800, 
height=(int)592, framerate=(fraction)0/1, bpp=(int)24, depth=(int)24, 
endianness=(int)4321, red_mask=(int)255, green_mask=(int)65280, 
blue_mask=(int)16711680")
     self.source.set_property('caps', self.caps)

     self.source.connect("need-data", self.need_data)

     self.bus = self.pipeline.get_bus()
     self.bus.add_signal_watch_full(1)
     self.bus.connect("message", self.on_message)

  def need_data(self, src, need_bytes):
     #getting data here
     src.emit("push-buffer", buf)

   def on_message(self, bus, msg):
     print 'Message: ', msg.type, msg

if __name__ == "__main__":


   p = Publisher()

   p.pipeline.set_state(gst.STATE_PLAYING)

   loop = gobject.MainLoop()
   loop.run()

all works great, but sometimes program prints error:

ERROR: WriteN, RTMP send error 9
ERROR: WriteN, RTMP send error 9
ERROR: WriteN, RTMP send error 9
.....


I want to handle this error to restart pipeline, but on_message does not 
recieve anything. Help me please.

P.S. Sorry for my english, it's not native.


More information about the gstreamer-devel mailing list