<div dir="ltr">i use RGBA to pack gray16 into an efficient RTP approved format. <div><a href="https://wiki.idiot.io/raw">https://wiki.idiot.io/raw</a>  <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 24, 2020 at 5:48 PM Nicolas Dufresne <<a href="mailto:nicolas@ndufresne.ca">nicolas@ndufresne.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Le vendredi 24 avril 2020 à 12:14 +0200, Milian Wolff a écrit :<br>
> 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" 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" 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" 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>
As the driver author mention, they converter driver does not support<br>
RGBA (it's such a rare format afaic). I would suggest you to introduce <br>
glcolorconvert element right before gldownload. It's even likely that<br>
the converter won't be required afterward, as the GPU will take care of<br>
the color conversion.<br>
<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" target="_blank">https://www.raspberrypi.org/forums/download/file.php</a>?<br>
> id=36357&sid=376f023986c765adc4950fe5e1335652<br>
> <br>
> Thanks a lot<br>
> _______________________________________________<br>
> gstreamer-devel mailing list<br>
> <a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org" target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div>