<div dir="auto">You should consider converting to yuv on the opengl side. Saving transfer penelty to/from gpu. <div dir="auto"><div dir="auto"><br></div><div dir="auto">Nvidia has a strain of gstreamer that handles converting on the gpu. For Jetson platform. </div><div dir="auto">Also ridgerun is active there with gstisp, not sure about raspi support. <br></div><div dir="auto"><br></div><div dir="auto"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 24, 2020, 13:15 Milian Wolff <<a href="mailto:milian.wolff@kdab.com">milian.wolff@kdab.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey there!<br>
<br>
this is a re-post of [1] to this mailing list, as I was directed here.<br>
<br>
[1]: <a href="https://www.raspberrypi.org/forums/viewtopic.php" rel="noreferrer noreferrer" target="_blank">https://www.raspberrypi.org/forums/viewtopic.php</a>?<br>
f=70&t=271720&sid=c5b8e22d61541521d6509330663b5fa8<br>
<br>
We are trying to optimize a gstreamer pipeline running on a rpi3b+ where, <br>
according to gst-shark, the current main bottleneck is a videoconvert element. <br>
That one is necessary to convert OpenGL frames in RGBA format to YUV for <br>
omxh264enc. This is a simplified example pipeline:<br>
<br>
```<br>
gst-launch-1.0 gltestsrc  \<br>
  ! "video/x-raw(memory:GLMemory),format=RGBA,width=640,height=480" \<br>
  ! gldownload ! queue \<br>
  ! videoconvert \<br>
  ! omxh264enc ! avimux ! filesink location=test.avi<br>
```<br>
<br>
My first approach was trying to get omxh264enc work directly with RGBA frames, <br>
see: <a href="https://gitlab.freedesktop.org/gstreamer/gst-omx/-/merge_requests/62" rel="noreferrer noreferrer" target="_blank">https://gitlab.freedesktop.org/gstreamer/gst-omx/-/merge_requests/62</a><br>
<br>
This in turn led me to v4l2convert and v4l2h264enc (see https://<br>
<a href="http://www.raspberrypi.org/forums/viewtopic.php?t=245852" rel="noreferrer noreferrer" target="_blank">www.raspberrypi.org/forums/viewtopic.php?t=245852</a>). We have now updated our <br>
stack to the following versions:<br>
<br>
```<br>
linux 4.19.88<br>
gstreamer 1.16.1<br>
```<br>
<br>
When I replace the omxh264enc with v4l2h264enc I run into the first issue:<br>
<br>
```<br>
gst-launch-1.0 gltestsrc  \<br>
  ! "video/x-raw(memory:GLMemory),format=RGBA,width=640,height=480" \<br>
  ! gldownload ! queue \<br>
  ! videoconvert \<br>
  ! v4l2h264enc ! avimux ! filesink location=test.avi<br>
<br>
ERROR: from element /GstPipeline:pipeline0/GstGLTestSrc:gltestsrc0: Internal <br>
data stream error.<br>
Additional debug info:<br>
../../../../gstreamer-1.16.1/libs/gst/base/gstbasesrc.c(3072): <br>
gst_base_src_loop (): /GstPipeline:pipeline0/GstGLTestSrc:gltestsrc0:<br>
streaming stopped, reason not-negotiated (-4)<br>
```<br>
<br>
Can someone explain what's going on here? I've also tried adding a <br>
`glcolorconvert ! "video/x-raw(memory:GLMemory),format=BGRA"` before the <br>
gldownload, but to no avail.<br>
<br>
The full output with GST_DEBUG="*:3" is:<br>
<br>
```<br>
Setting pipeline to PAUSED ...<br>
0:00:00.238494323  1765  0x2361ba0 WARN                    v4l2 <br>
gstv4l2object.c:4196:gst_v4l2_object_probe_caps:<v4l2h264enc0:src> Failed to <br>
probe pixel aspect ratio with VIDIOC_CROPCAP: Invalid argument<br>
Pipeline is PREROLLING ...<br>
0:00:00.242415365  1765  0x23386c0 FIXME                default gstutils.c:<br>
3981:gst_pad_create_stream_id_internal:<gltestsrc0:src> Creating random <br>
stream-id, consider implementing a deterministic way of creating a stream-id<br>
Got context from element 'gldownloadelement0': gst.gl.GLDisplay=context, <br>
gst.gl.GLDisplay=(GstGLDisplay)"\(GstGLDisplayEGL\)\ gldisplayegl0";<br>
0:00:00.264218855  1765  0x23381b0 WARN           basetransform <br>
gstbasetransform.c:1364:gst_base_transform_setcaps:<videoconvert0> transform <br>
could not transform video/x-raw, format=(string)RGBA, width=(int)640, <br>
height=(int)480, framerate=(fraction)30/1, interlace-mode=(string)progressive <br>
in anything we support<br>
0:00:00.271333542  1765  0x23381b0 WARN           basetransform <br>
gstbasetransform.c:1364:gst_base_transform_setcaps:<videoconvert0> transform <br>
could not transform video/x-raw, format=(string)RGBA, width=(int)640, <br>
height=(int)480, framerate=(fraction)30/1, interlace-mode=(string)progressive <br>
in anything we support<br>
0:00:00.271435157  1765  0x23381b0 WARN                GST_PADS gstpad.c:<br>
4231:gst_pad_peer_query:<queue0:src> could not send sticky events<br>
0:00:00.293517917  1765  0x23581b0 FIXME              glslstage <br>
gstglslstage.c:518:_compile_shader:<glslstage0> vertex shader info <br>
log:Compiled<br>
0:00:00.294581980  1765  0x23581b0 FIXME              glslstage <br>
gstglslstage.c:518:_compile_shader:<glslstage1> fragment shader info <br>
log:Compiled<br>
0:00:00.306531615  1765  0x23581b0 FIXME              glslstage <br>
gstglslstage.c:518:_compile_shader:<glslstage2> vertex shader info <br>
log:Compiled<br>
0:00:00.307533698  1765  0x23581b0 FIXME              glslstage <br>
gstglslstage.c:518:_compile_shader:<glslstage3> fragment shader info <br>
log:Compiled<br>
0:00:00.342931927  1765  0x23381b0 WARN           basetransform <br>
gstbasetransform.c:1364:gst_base_transform_setcaps:<videoconvert0> transform <br>
could not transform video/x-raw, format=(string)RGBA, width=(int)640, <br>
height=(int)480, framerate=(fraction)30/1, interlace-mode=(string)progressive <br>
in anything we support<br>
0:00:00.350237917  1765  0x23381b0 WARN           basetransform <br>
gstbasetransform.c:1364:gst_base_transform_setcaps:<videoconvert0> transform <br>
could not transform video/x-raw, format=(string)RGBA, width=(int)640, <br>
height=(int)480, framerate=(fraction)30/1, interlace-mode=(string)progressive <br>
in anything we support<br>
0:00:00.354808438  1765  0x23386c0 WARN                 basesrc gstbasesrc.c:<br>
3072:gst_base_src_loop:<gltestsrc0> error: Internal data stream error.<br>
0:00:00.355374011  1765  0x23386c0 WARN                 basesrc gstbasesrc.c:<br>
3072:gst_base_src_loop:<gltestsrc0> error: streaming stopped, reason not-<br>
negotiated (-4)<br>
0:00:00.356358646  1765  0x23386c0 WARN                   queue gstqueue.c:<br>
988:gst_queue_handle_sink_event:<queue0> error: Internal data stream error.<br>
ERROR: from element /GstPipeline:pipeline0/GstGLTestSrc:gltestsrc0: Internal <br>
data stream error.<br>
Additional debug info:<br>
../../../../gstreamer-1.16.1/libs/gst/base/gstbasesrc.c(3072): <br>
gst_base_src_loop (): /GstPipeline:pipeline0/GstGLTestSrc:gltestsrc0:<br>
streaming stopped, reason not-negotiated (-4)<br>
ERROR: pipeline doesn't want to preroll.<br>
Setting pipeline to NULL ...<br>
0:00:00.357002709  1765  0x23386c0 WARN                   queue gstqueue.c:<br>
988:gst_queue_handle_sink_event:<queue0> error: streaming stopped, reason not-<br>
negotiated (-4)<br>
Freeing pipeline ...<br>
```<br>
<br>
I can manage to workaround this by explicitly letting the videoconvert do the <br>
YUV conversion like this:<br>
<br>
```<br>
gst-launch-1.0 gltestsrc  \<br>
  ! "video/x-raw(memory:GLMemory),format=RGBA,width=640,height=480" \<br>
  ! gldownload ! queue \<br>
  ! videoconvert ! "video/x-raw,format=I420" \<br>
  ! v4l2h264enc ! avimux ! filesink location=test.avi<br>
```<br>
<br>
No more errors, but the resulting test.avi file is completely broken. I can <br>
play it with cvlc but its all green and garbled... Can someone explain what's <br>
going on here?<br>
<br>
Now, let's try to stick to omxh264enc and replace videoconvert instead:<br>
<br>
```<br>
gst-launch-1.0 gltestsrc  \<br>
  ! "video/x-raw(memory:GLMemory),format=RGBA,width=640,height=480" \<br>
  ! gldownload ! queue \<br>
  ! v4l2convert \<br>
  ! omxh264enc ! avimux ! filesink location=test.avi<br>
<br>
WARNING: erroneous pipeline: could not link queue0 to v4l2convert0<br>
```<br>
<br>
Which is odd, but expected considering the following:<br>
<br>
```<br>
gst-inspect-1.0 v4l2convert<br>
...<br>
      video/x-raw<br>
                 format: { (string)YUY2, (string)YVYU, (string)UYVY, <br>
(string)I420, (string)YV12, (string)RGB, (string)BGR, (string)BGR<br>
x, (string)BGRA, (string)RGB16, (string)NV12, (string)NV21 }<br>
                  width: [ 1, 32768 ]<br>
                 height: [ 1, 32768 ]<br>
              framerate: [ 0/1, 2147483647/1 ]<br>
```<br>
<br>
So, why is RGBA not supported here? Well, let's try to add a glcolorconvert to <br>
BGRA, but that fails too:<br>
<br>
```<br>
gst-launch-1.0 gltestsrc  \<br>
  ! "video/x-raw(memory:GLMemory),format=RGBA,width=640,height=480" \<br>
  ! glcolorconvert ! "video/x-raw(memory:GLMemory),format=BGRA" \<br>
  ! gldownload ! queue \<br>
  ! v4l2convert \<br>
  ! omxh264enc ! avimux ! filesink location=test.avi<br>
<br>
ERROR: from element /GstPipeline:pipeline0/GstGLTestSrc:gltestsrc0: Internal <br>
data stream error.<br>
Additional debug info:<br>
../../../../gstreamer-1.16.1/libs/gst/base/gstbasesrc.c(3072): <br>
gst_base_src_loop (): /GstPipeline:pipeline0/GstGLTestSrc:gltestsrc0:<br>
streaming stopped, reason not-negotiated (-4)<br>
ERROR: pipeline doesn't want to preroll.<br>
```<br>
<br>
I've tried some of the other RGB formats, but none seem to work here. What am <br>
I missing?  I've attached the full `:4 GST_DEBUG trace log` file over on the <br>
rpi forum at [2]<br>
<br>
[2]: <a href="https://www.raspberrypi.org/forums/download/file.php" rel="noreferrer noreferrer" target="_blank">https://www.raspberrypi.org/forums/download/file.php</a>?<br>
id=36357&sid=376f023986c765adc4950fe5e1335652<br>
<br>
Thanks a lot<br>
-- <br>
Milian Wolff | <a href="mailto:milian.wolff@kdab.com" target="_blank" rel="noreferrer">milian.wolff@kdab.com</a> | Senior Software Engineer<br>
KDAB (Deutschland) GmbH, a KDAB Group company<br>
Tel: +49-30-521325470<br>
KDAB - The Qt, C++ and OpenGL Experts_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank" rel="noreferrer">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div>