使用 omxh264enc 编码失败!

使用 python 运行 gst 时,执行以下命令:

 launch_string = 'appsrc name=source is-live=true block=true format=GST_FORMAT_TIME ' \
                  f'caps=video/x-raw,format=BGR,width=1920,height=1080,framerate=20/1 ' \
                  f'! autovideoconvert ! video/x-raw,format=I420,width=1920,height=1080,framerate=20/1 ' \
                  '! omxh264enc speed-preset=ultrafast tune=zerolatency ' \
                  '! rtph264pay config-interval=1 name=pay0 pt=96'

使用 vlc 访问该流时,有如下报错:

gi.repository.GLib.GError: gst_parse_error: no element "omxh264enc" (1)

(python:572752): GStreamer-RTSP-Server-CRITICAL **: 03:47:09.978: could not create element

执行插件检查,提示如下:

$ gst-inspect-1.0 | grep omx
libav:  avenc_h264_omx: libav OpenMAX IL H.264 video encoder encoder
libav:  avenc_mpeg4_omx: libav OpenMAX IL MPEG-4 video encoder encoder

$ gst-inspect-1.0 omxh264enc
没有那样的组件或插件‘omxh264enc’

以上问题,如何解决?

hello 1930920921,

is it a must for using H264? could you please give it a try with H265?
for instance, please see-also Topic 292692, which executed nvv4l2camerasrc plugin for RTSP streaming with H265.

感谢您的回复。我尝试了您的建议,目前已经可以正常编码,但延迟约10~15s,具体代码如下:

launch_string = 'appsrc name=source ' \
               f'caps=video/x-raw,format=UYVY ' \
               f'! nvvidconv ! video/x-raw(memory:NVMM),format=NV12 ' \
               '! nvv4l2h265enc ! h265parse ' \
               '! rtph265pay name=pay0 pt=96'

目前,我获取摄像头的方法来自:

cv2.VideoCapture("<camera_rtsp_url>")

如何在仍然使用摄像头rtsp的条件下,使用 GPU 的方式解码图像?解码的图像需要回调至 python 中,因为还需要做推理。

hello 1930920921,

is such delay caused by openCV? or… did you still observe 15-sec delay by preview frames?
you may see-also Topic 183388 for setting up the pipeline for testing.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.