Esempio n. 1
0
        device, caps_str = response['device'], response['caps_str']

        for i in range(2):
            response = p(command='create', device=device,
                    caps_str=caps_str, bitrate=150000,
                            output_path='test_output.avi', ack=True)
            logging.info('[response] %s' % response)

            response = p(command='start', ack=True)
            logging.info('[response] %s' % response)
            time.sleep(5)

            p(command='stop')
            response = p(command='create', device=None, ack=True,
                    caps_str='video/x-raw-yuv,width=640,height=480,fourcc=YUY2'\
                            ',framerate=30/1')
            logging.info('[response] %s' % response)
            p(command='start')
            logging.info('[response] %s' % response)

            time.sleep(3)
            p(command='stop')
        p(command='join')
    except (Exception, ), why:
        traceback.print_stack()
        traceback.print_exc()
        p.terminate()
        raise
    else:
        p.join()
Esempio n. 2
0
    parser.add_argument("--force_aspect_ratio", action="store_true")
    parser.add_argument("port", default=8080, type=int, nargs="?")
    args = parser.parse_args()

    return args


if __name__ == "__main__":
    logging.basicConfig(format="[%(levelname)s] %(message)s", loglevel=logging.INFO)

    args = parse_args()
    print args

    # Create a GStreamer window server process, with an initial `window_xid`
    # set to zero.  The `window_xid` can be set via the server proxy API to
    # specify which window buffer the GStreamer frames should be drawn to.
    service = WindowProcess(0, port=args.port, force_aspect_ratio=args.force_aspect_ratio)

    logging.info("Starting server")
    service.start()

    port = service.parent_pipe.recv()
    logging.info("Received port %s from child process", port)

    try:
        service.join()
    except KeyboardInterrupt:
        pass
    finally:
        service.terminate()