I am able to record videos using the Gst.parse_launch() utility, it waits for EOF and gracefully closes the files. When I tee the encoded streams for liveViews, while recording, I have to create elements on the go, which I am pretty sure I am doing correctly; however, I want to reduce or rescale the liveView stream to avoid 2 1080p or 4K video streams running simultaneously. So, is it possible to add rescaling in the liveView tee, and at the same time record videos at 4K or 1080p?
cameraPipeline = Gst.parse_launch(
"XXXXcamerasrc\
! video/x-h265,width=1280,height=720,framerate=25/1,stream-format=byte-stream,bitrate=8000000,profile=high,bitrate-control-mode=vbr\
! h265parse\
! tee name=t\
! queue\
! splitmuxsink\
location=/mnt/media/output.mp4\
max-size-bytes=1000000000 "
)
t = cameraPipeline.get_by_name("t")
cameraPipeline.set_state(Gst.State.PLAYING)
liveBranch = {}
def liveView(host="10.42.0.10", port=5000):
if len(liveBranch) == 0:
print("Starting live view")
# Create a new branch for live view
q = Gst.ElementFactory.make("queue", "liveQueue")
rtppay = Gst.ElementFactory.make("rtph265pay", "rtpPay")
udpsink = Gst.ElementFactory.make("udpsink", "udpSink")
udpsink.set_property("host", host)
udpsink.set_property("port", port)
for e in [q, rtppay, udpsink]:
if not e:
print(f"Failed to create element: {e.get_name()}")
sys.exit(1)
cameraPipeline.add(e)
e.sync_state_with_parent()
pad = t.get_request_pad("src_%u")
pad.link(q.get_static_pad("sink"))
q.link(rtppay)
rtppay.link(udpsink)
# liveBranch.update([q, rtppay, udpsink])
liveBranch.update(q=q,rtppay=rtppay,udpsink=udpsink,pad=pad)
print("Live view branch created and linked")
print("Live view started at {}:{}".format(host, port))
if not liveBranch:
print("Failed to link live view branch")
sys.exit(1)
else:
print("Live view already started")
To test it, I am using the CLI to create and destroy elements on the go.