You may try something like this (assuming your V4L cam supports 1920x1080@60fps):
#!/usr/bin/env python
import signal
import sys
import time
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst, GObject
# Signal handler stopping the pipeline before exit
def signal_handler(sig, frame):
p.set_state(Gst.State.NULL)
sys.exit(0)
GObject.threads_init()
Gst.init(None)
gst_str = "v4l2src device=/dev/video0 ! video/x-raw,width=1920,height=1080, framerate=60/1 ! timeoverlay ! nvvidconv ! video/x-raw(memory:NVMM),format=I420 ! tee name=t \
t. ! queue ! nvvidconv ! video/x-raw, format=BGRx,width=400,height=400,pixel-aspect-ratio=1/1 ! videoconvert ! video/x-raw, format=BGR ! appsink \
t. ! queue ! nvjpegenc ! jpegparse ! rtpjpegpay ! udpsink host=127.0.0.1 port=5000"
# Create the pipeline
p = Gst.parse_launch (gst_str)
# Register signal handler for proper termination if receiving SIGINT such as Ctrl-C
signal.signal(signal.SIGINT, signal_handler)
# Start the pipeline
p.set_state(Gst.State.READY)
p.set_state(Gst.State.PAUSED)
p.set_state(Gst.State.PLAYING)
# Run for 10s
time.sleep(10)
# Done. Stop the pipeline before clean up on exit.
p.set_state(Gst.State.NULL)
exit(0)
timeoverlay and videoconvert may generate some CPU load for high resolutions.