I want to using gstreamer pipeline to convert image to rtsp ,but i got a low resolution of video streaming , please help me 。
following is the environment and version
gi :3.26.1
docker :nvcr.io/nvidia/l4t-base:r32.4.2
opencv :4.1.1
gstreamer :1.14.5
jetson nano :2G
python :3.6.9
show info list:
- part 1(udpsink ,problem)
- part 2 (udpsrc,no problem)
- comple code
- print info
- open streaming in VLC (media player)
- part 1(udpsink ,problem)
out_send = cv2.VideoWriter(
‘appsrc is-live=true ! videoconvert ! omxh264enc bitrate=12000000 ! video/x-h264, stream-format=byte-stream ! rtph264pay pt=96 ! udpsink host=127.0.0.1 port=5400 async=false’,
cv2.CAP_GSTREAMER, 0, 25, (1920,1080), True)
- part 2 (udpsrc,no problem)
factory.set_launch(“(udpsrc name=pay0 port=5400 buffer-size=524288
caps="application/x-rtp, media=video, clock-rate=90000,
encoding-name=(string)H264, payload=96 ")”)
- comple code
#!/usr/bin/env python
import cv2
import gi
gi.require_version(‘Gst’, ‘1.0’)
gi.require_version(‘GstRtspServer’, ‘1.0’)
from gi.repository import GObject, Gst, GstRtspServerdef main():
out_send = cv2.VideoWriter('appsrc is-live=true ! videoconvert ! \ omxh264enc bitrate=12000000 ! video/x-h264, \ stream-format=byte-stream ! rtph264pay pt=96 ! \ udpsink host=127.0.0.1 port=5400 async=false', cv2.CAP_GSTREAMER, 0, 30, (1920,1080), True) if not out_send.isOpened(): print('VideoWriter not opened') exit(0) rtsp_port_num = 8554 server = GstRtspServer.RTSPServer.new() server.props.service = "%d" % rtsp_port_num server.attach(None) factory = GstRtspServer.RTSPMediaFactory.new() factory.set_launch("(udpsrc name=pay0 port=5400 buffer-size=524288 \ caps=\"application/x-rtp, media=video, clock-rate=90000, \ encoding-name=(string)H264, payload=96 \")") factory.set_shared(True) server.get_mount_points().add_factory("/ds-test", factory) # output rtsp info print("\n *** Launched RTSP Streaming at rtsp://localhost:%d/ds-test ***\n\n" % rtsp_port_num) cap = cv2.VideoCapture(0) while True: _, mat = cap.read() #do someting inference out_send.write(mat) cv2.waitKey(30)
if name == ‘main’:
main()
- print info
Framerate set to : 25 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4*** Launched RTSP Streaming at rtsp://localhost:8554/ds-test ***
H264: Profile = 66, Level = 40
- open streaming in VLC (media player)
low resolution of video streaming
normal of video streaming