Advertisement
dougroyal

Untitled

Nov 23rd, 2011
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. I used gstreamer on the server (running voyage linux). This was part of a larger script that did some tests to make sure the camera was present and setup the client host IP dynamically. My ROV was actually a DHCP server, so it assigned the client's IP, but these snippets work without all that complexity.
  2.  
  3. $ gst-launch v4l2src device=/dev/video0 ! videoscale ! video/x-raw-yuv,framerate=30/1 ! ffmpegcolorspace ! jpegenc ! tcpserversink host=192.168.1.6 port=35890
  4.  
  5. You can easily test this on a client with this command. Here "host" is the server IP
  6.  
  7. $ gst-launch tcpclientsrc host=192.168.1.1 port=35890 ! jpegdec ! autovideosink
  8.  
  9. The actual client was a python/GTK application, here's the relevant code:
  10.  
  11. You'll need gobject, gtk, and pygst. See the gstpython site for more documentation:
  12. http://gstreamer.freedesktop.org/modules/gst-python.html
  13.  
  14. class RovGui():
  15.  
  16. def __init__(self):
  17.  
  18. # snip #
  19.  
  20. # setup remote camera stream
  21. self.player = gst.parse_launch("tcpclientsrc host=" + self.rov_server_ip + " port=35890 ! jpegdec ! autovideosink")
  22.  
  23. bus = self.player.get_bus()
  24. bus.add_signal_watch()
  25. bus.enable_sync_message_emission()
  26. bus.connect("message", self.on_message)
  27. bus.connect("sync-message::element", self.on_sync_message)
  28.  
  29. self.player.set_state(gst.STATE_PLAYING)
  30.  
  31. # handle messages coming from video thread
  32. def on_message(self, bus, message):
  33. t = message.type
  34. if t == gst.MESSAGE_EOS:
  35. self.player.set_state(gst.STATE_NULL)
  36. elif t == gst.MESSAGE_ERROR:
  37. err, debug = message.parse_error()
  38. print "Error: %s" % err, debug
  39. self.player.set_state(gst.STATE_NULL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement