s.bind(('0.0.0.0', 5806)) s.listen(1) conn, _ = s.accept() logger.debug('Got incoming time socket connection') time = conn.recv(200) logger.info('Got time %s', time) pipeline = gs.pipeline( # gs.PipelinePart('v4l2src device=/dev/video0 name=pipe_src ! video/x-h264,width=1280,height=720,framerate=15/1,profile=baseline') + gs.H264Stream(port=5002) # Default to port 5002 gs.PipelinePart(( 'uvch264src device=/dev/video{} name=pipe_src auto_start=true initial-bitrate=1500000 ' # 'initial-bitrate=3000000 average-bitrate=3000000 peak-bitrate=5000000 ' # 'rate-control=vbr iframe-period=1000 ' 'pipe_src.vfsrc ! queue ! video/x-raw,format=YUY2,width=320,height=240,framerate=10/1 ! fakesink ' 'pipe_src.vidsrc ! queue ! video/x-h264,width=1280,height=720,framerate=30/1 ' ).format(camera)) + gs.Valve('valve') + gs.Tee( 'tee', gs.H264Stream(port=5002), # Default to port 5002 gs.PipelinePart('filesink append=true location=/mnt/usb/video/' + gs.ts_filename()))) # Alternative: # gst-launch-1.0 -v -e pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start
import networking.messages as m from processing.tapecontours import get_corners_from_image Gst = gs.Gst if __name__ == '__main__': conf = config.configfor('Vision') logging.config.dictConfig(conf.logging) logger = logging.getLogger(__name__) gs.delete_socket() pipeline = gs.pipeline( gs.RaspiCam(**conf.params) + gs.Tee('t', gs.Valve('valve') + gs.H264Video() + gs.H264Stream(), gs.SHMSink())) pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start logger.debug(pipeline.get_state( Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play caps = gs.get_sink_caps(pipeline.get_by_name(gs.SINK_NAME)) cap_string = gs.make_command_line_parsable(caps)
""" import threading import cv2 import gstreamer as gs import networking import networking.messages as m from processing.tapecontours import get_corners_from_image Gst = gs.Gst if __name__ == '__main__': gs.delete_socket() pipeline = gs.pipeline(gs.RaspiCam() + gs.Tee('t', gs.Valve('valve') + gs.H264Stream(), gs.SHMSink())) pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start print(pipeline.get_state(Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play caps = gs.get_sink_caps(pipeline.get_by_name(gs.SINK_NAME)) cap_string = gs.make_command_line_parsable(caps) cap = cv2.VideoCapture(gs.SHMSrc(cap_string))
""" This program serves a stream of the camera with autofocus turned off. """ import threading import gstreamer as gs import networking Gst = gs.Gst if __name__ == '__main__': pipeline = gs.pipeline( gs.RaspiCam(awb=True, expmode=1) + gs.Valve('valve') + gs.H264Stream(port=5002) # Default to port 5002 ) pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start print(pipeline.get_state(Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play # Now that the pipeline has been (hopefully) successfully started, # GStreamer doesn't need to be debugged anymore and the thread can be # stopped. debuggingThread.stop() # Set up server sock, clis = networking.server.create_socket_and_client_list() handler = networking.create_gst_handler(pipeline, None, 'valve',
import logging import logging.config import threading import time import config import gstreamer as gs import networking Gst = gs.Gst if __name__ == '__main__': conf = config.configfor('Driver') logging.config.dictConfig(conf.logging) logger = logging.getLogger(__name__) pipeline = gs.pipeline( gs.H264RaspiCam(**conf.params) + gs.Valve('valve') + gs.H264Stream(port=5002) # Default to port 5002 ) pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start logging.debug(pipeline.get_state( Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play # Now that the pipeline has been (hopefully) successfully started, # GStreamer doesn't need to be debugged anymore and the thread can be # stopped.
rcrns = [(cx-w, cy-h), (cx+w, cy-h), (cx+w, cy+h), (cx-w, cy+h)] random.shuffle(rcrns) return rcrns if __name__ == '__main__': conf = config.configfor('Vision') # logging.config.dictConfig(conf.logging) # logger = logging.getLogger(__name__) pipeline = gs.pipeline( gs.TestSrc() + gs.H264Video(h264encoder='x264enc') + #gs.Tee( # 't', gs.Valve('valve') + gs.H264Stream(port=5805, host='localhost')#, # gs.TSFile(gs.ts_filename(), False) #) ) pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start print(pipeline.get_state(Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play # Now that the pipeline has been (hopefully) successfully started, # GStreamer doesn't need to be debugged anymore and the thread can be # stopped.
OUT = 'rtpmp2tpay pt=96 ! udpsink name={udp_name} host={host} port={port} async=false'.format( **gs.DEFAULTS) if __name__ == '__main__': conf0 = config.configfor('Driver') conf1 = config.configfor('Gear') logging.config.dictConfig(conf0.logging) logger = logging.getLogger(__name__) pipeline = gs.pipeline( # str(gs.PipelinePart('mpegtsmux name=mux') + gs.Valve('valve') + gs.PipelinePart(OUT)) # + ' ' + STREAM.format(0) + '! mux.sink_0 ' + STREAM.format(1) + '! mux.sink_1' # gs.PipelinePart('v4l2src device=/dev/video0 name=pipe_src ! video/x-h264,width=1280,height=720,framerate=15/1,profile=baseline') + gs.H264Stream(port=5002) # Default to port 5002 str( gs.PipelinePart(STREAM.format(0)) + gs.Valve('valve0') + gs.H264Stream(port=5030, udp_name='udpsink0')) + ' ' + str( gs.PipelinePart(STREAM.format(1)) + gs.Valve('valve1') + gs.H264Stream(port=5031, udp_name='udpsink1'))) pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start logging.debug(pipeline.get_state( Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play # Now that the pipeline has been (hopefully) successfully started,
gs.delete_socket() pipeline = gs.pipeline( gs.RaspiCam(vflip=True, hFlip=True, expmode=6, framerate=30, ec=10, awb=False, ar=1, ab=2.5, width=1280, height=960) + gs.PipelinePart('videoconvert') + gs.Tee( 't', gs.Valve('valve') + gs.H264Video() + gs.H264Stream(), gs.PipelinePart('videoscale ! video/x-raw, width=640, height=480') + gs.SHMSink())) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() pipeline.set_state(Gst.State.PLAYING) logger.debug(pipeline.get_state(Gst.CLOCK_TIME_NONE)) caps = gs.get_sink_caps(pipeline.get_by_name(gs.SINK_NAME)) cap_string = gs.make_command_line_parsable(caps) vc = VideoCapture(gs.SHMSrc(cap_string))
import logging.config import threading import time import config import gstreamer as gs import networking Gst = gs.Gst if __name__ == '__main__': conf = config.configfor('Gear') logging.config.dictConfig(conf.logging) logger = logging.getLogger(__name__) pipeline = gs.pipeline( gs.Webcam(**conf.params) + gs.Valve('valve') + gs.H264Video() + gs.H264Stream(port=5002) # Default to port 5002 ) pipeline.set_state(Gst.State.PLAYING) # Start debugging the gstreamer pipeline debuggingThread = gs.MessagePrinter(pipeline) debuggingThread.start() # TODO: Find a better method to wait for playback to start logging.debug(pipeline.get_state( Gst.CLOCK_TIME_NONE)) # Wait for pipeline to play # Now that the pipeline has been (hopefully) successfully started, # GStreamer doesn't need to be debugged anymore and the thread can be # stopped.