Recording RTSP stream with Gstreamer

Hi,
Device Jetson NX

I want to read a file name “test/video6.mp4” that is 4K video with resolution 3840x2160. I wana read this using gpu and gtreamer to dont have lag when i display it (if i decode with CPU will have lag). I wana stream this video on rtsp link source so that i can read it with something else while is still streaming.

This command works running my video with GPU wihout any lag or problem but it displays on display not in rtsp
“gst-launch-1.0 filesrc location=test/video6.mp4 ! qtdemux name=demux demux.video_0 ! queue ! h264parse ! omxh264dec ! nveglglessink”

Code looks like:
‘’’
noh = NvidiaOpenCVHelp()
first_frame, last_frame, width, height = noh.getCornerFrames(“video6.mp4”)
cmd = [“gst-launch-1.0”,
“filesrc”, “location=test/video6.mp4”, “!”,
“qtdemux”, “name=demux”, “demux.video_0”, “!”,
“queue”, “!”,
“h264parse”, “!”,
“omxh264dec”, “!”,
“nveglglessink”
]
gst1 = sp.Popen(cmd, stdout = sp.PIPE, bufsize=10, )

w=width
h=height
k = w*h
head_length = 528
x = gst1.stdout.read(int(w*h*4))

‘’’

With other words:

What i wana reach is create an python app, i have setup mqtt broker + python code to send message in between two topics depending on detections and everything on that part but i am stuck on switching schemes:
Scheme 1* When mqtt broker has an notification message on topic “test/play_video” then python app should display an video carosel playing local videos one by one like in browser. Then i wana add some transition in between videos this is only first part
To archive transiton i will cut only first and last frame from videos with opencv (processing with cpu but its just 2 frames so it will not take longer)

Code looks like:
‘’’

@frame1 = last_frame of current video that is playing

@frame2 = first_frame of next video that will be played next

def fadeIn(frame2, frame1, len = 20):
for i in range(0, len):
fadein = i/float(len)
# Method 2
mean = cv2.addWeighted(frame2, 1-fadein, frame1, fadein,0)

	# Note that the division by 255 results in the image array values being squeezed to [0,1].
	mean = mean/255.
	yield mean

for mean in fadeIn(frame2, frame1):
print(c);c+=1
mean = cv2.resize(mean, (0,0), fx=1.0, fy=1.0)
frame = cv2.imencode(‘.jpg’, frame1)[1].tobytes()
yield (b’–frame\r\n’b’Content-Type: image/jpeg\r\n\r\n’ + frame + b’\r\n’)
‘’’

Scheme 2* When mqtt broker has an notification message on topic “test/play_horizon”, python app should render/display an vueJS webpage “https://www.example.com

– Note all my local videos are in 4K

Hi,
You can try to launch RTSP server through test-mp4. Please take a look at
the cpu usage cannot down (use cuda decode) - #18 by DaneLLL