Problem with nveglstreamsrc

Hi,
I’m trying to use nveglstreamsrc on TX1, and tyied the following two codes:
https://github.com/DaneLLL/gstreamer_eglstreamsrc
https://github.com/DaneLLL/simpleEGLStreams_producer
But didn’t get them run. I modified a little bit with two pipelines, and printout some info:
The first one:

Using launch string: nveglstreamsrc name=egl_src ! video/x-raw(memory:NVMM), format=I420, width=1280, height=720, framerate=30/1 ! omxh264enc bitrate=2500000 name=video_enc iframeinterval=15 profile=high low-latency=false control-rate=4 ! queue ! video/x-h264, stream-format=byte-stream  ! fakesink 
NVEGLStreamProducer: start_eglstream_producer ++
eglDisplay Handle created 
EGLStream initialized
NVEGLStreamProducer: start_eglstream_producer --
display 0x64c490, stream 0x66f791
Thread created

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
Obtained EGLConfig and EGLContext
Bound layer to rendering surface
eglSwapBuffers_wrapper---: 1
NvMSEncCheckInputSurface:327: Only Blocklinear and Pitch surface format allowed
VENC: VideoEncInputProcessing: 4367:  VideoEncFeedImage failed. Input buffer 0 sent
VENC: NvMMLiteVideoEncDoWork: 4989: BlockSide error 0x4
Event_BlockError from 0BlockAvcEnc : Error code - 4
Sending error event from 0BlockAvcEnceglSwapBuffers_wrapper---: 1
frame = 1
eglSwapBuffers_wrapper---: 1
frame = 2
eglSwapBuffers_wrapper---: 1
frame = 3
eglSwapBuffers_wrapper---: 0
frame = 4
eglSwapBuffers_wrapper---: 0
frame = 5
eglSwapBuffers_wrapper---: 0
frame = 6
eglSwapBuffers_wrapper---: 0
frame = 7
.
.
.

and the second one:

Using launch string: nveglstreamsrc name=egl_src ! video/x-raw(memory:NVMM), format=I420, width=1280, height=720, framerate=30/1 ! nvegltransform ! nveglglessink -e
NVEGLStreamProducer: start_eglstream_producer ++
eglDisplay Handle created 
EGLStream initialized
NVEGLStreamProducer: start_eglstream_producer --
Thread created
display 0x63c610, stream 0x65f6c1

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Obtained EGLConfig and EGLContext
Bound layer to rendering surface
eglSwapBuffers_wrapper---: 1
Not supported input Rmsurface 
eglSwapBuffers_wrapper---: 1
frame = 1
eglSwapBuffers_wrapper---: 1
frame = 2
eglSwapBuffers_wrapper---: 1
frame = 3
eglSwapBuffers_wrapper---: 1
frame = 4
eglSwapBuffers_wrapper---: 0
frame = 5
eglSwapBuffers_wrapper---: 0
frame = 6
eglSwapBuffers_wrapper---: 0
frame = 7
.
.
.

Actually the producer is running, but eglSwapBuffers returns EGL_FALSE after some cycles.
What’s the problem?

Thanks!

Hi,
What is your BSP revision?

Hi DaneLLL,
Thank you very much for the quick reply.
JetPack 3.1; L4T r28.1

And I also print out some more gst debug info for these two pipelines:

Using launch string: nveglstreamsrc name=egl_src ! video/x-raw(memory:NVMM), format=I420, width=1280, height=720, framerate=30/1 ! omxh264enc bitrate=2500000 name=video_enc iframeinterval=15 profile=high control-rate=4 ! queue ! video/x-h264, stream-format=byte-stream  ! fakesink 
NVEGLStreamProducer: start_eglstream_producer ++
eglDisplay Handle created 
EGLStream initialized
NVEGLStreamProducer: start_eglstream_producer --
display 0x64c380, stream 0x66f681
Thread created

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
Obtained EGLConfig and EGLContext
Bound layer to rendering surface
eglSwapBuffers_wrapper---: 1
NvMSEncCheckInputSurface:327: Only Blocklinear and Pitch surface format allowed
VENC: VideoEncInputProcessing: 4367:  VideoEncFeedImage failed. Input buffer 0 sent
VENC: NvMMLiteVideoEncDoWork: 4989: BlockSide error 0x4
Event_BlockError from 0BlockAvcEnc : Error code - 4
Sending error event from 0BlockAvcEnc0:00:00.716821927  2042   0x7f740012f0 ERROR                    omx gstomx.c:504:EventHandler:<video_enc> encoder got error: Bad parameter (0x80001005)
0:00:00.716893073  2042       0x640770 ERROR                    omx gstomx.c:276:gst_omx_component_handle_messages:<video_enc> encoder got error: Bad parameter (0x80001005)
0:00:00.716933906  2042       0x640770 ERROR                    omx gstomx.c:1293:gst_omx_port_acquire_buffer:<video_enc> Component encoder is in error state: Bad parameter
eglSwapBuffers_wrapper---: 1
frame = 1
eglSwapBuffers_wrapper---: 1
frame = 2
eglSwapBuffers_wrapper---: 1
frame = 3
eglSwapBuffers_wrapper---: 0
frame = 4
eglSwapBuffers_wrapper---: 0
frame = 5
eglSwapBuffers_wrapper---: 0
frame = 6
eglSwapBuffers_wrapper---: 0
.
.
.
Using launch string: nveglstreamsrc name=egl_src ! video/x-raw(memory:NVMM), format=I420, width=1280, height=720, framerate=30/1 ! nvegltransform ! nveglglessink
NVEGLStreamProducer: start_eglstream_producer ++
eglDisplay Handle created 
EGLStream initialized
NVEGLStreamProducer: start_eglstream_producer --
display 0x63c500, stream 0x65f9d1
Thread created

NvEglStreamSrcInitializeEgl: Load library: libEGL.so
Obtained EGLConfig and EGLContext
Bound layer to rendering surface
eglSwapBuffers_wrapper---: 1
Not supported input Rmsurface 
0:00:00.670419688  2092       0x638190 ERROR         nvegltransform gstnvegltransform.c:286:gst_nvegl_transform_transform:<nvegltransform0> can't blit surface to EGLImage.
eglSwapBuffers_wrapper---: 1
frame = 1
eglSwapBuffers_wrapper---: 1
frame = 2
eglSwapBuffers_wrapper---: 1
frame = 3
eglSwapBuffers_wrapper---: 1
frame = 4
eglSwapBuffers_wrapper---: 0
frame = 5
eglSwapBuffers_wrapper---: 0
frame = 6
eglSwapBuffers_wrapper---: 0
frame = 7
eglSwapBuffers_wrapper---: 0
.
.
.

I also tried them on:
JetPack 3.3; L4T r28.2
but almost the same:

Using launch string: nveglstreamsrc name=egl_src ! video/x-raw(memory:NVMM), format=I420, width=1280, height=720, framerate=30/1 ! omxh264enc bitrate=2500000 name=video_enc iframeinterval=15 profile=high control-rate=4 ! queue ! video/x-h264, stream-format=byte-stream  ! fakesink 
NVEGLStreamProducer: start_eglstream_producer ++
eglDisplay Handle created 
EGLStream initialized
NVEGLStreamProducer: start_eglstream_producer --
display 0x645100, stream 0x6686a1
Thread created
Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== MSENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
Obtained EGLConfig and EGLContext
Bound layer to rendering surface
eglSwapBuffers_wrapper---: 1
NvMSEncCheckInputSurface:327: Only Blocklinear and Pitch surface format allowed
VENC: VideoEncInputProcessing: 4376:  VideoEncFeedImage failed. Input buffer 0 sent
VENC: NvMMLiteVideoEncDoWork: 5001: BlockSide error 0x4
Event_BlockError from 0BlockAvcEnc : Error code - 4
Sending error event from 0BlockAvcEnc0:00:00.669944218  3124   0x7f90001950 ERROR                    omx gstomx.c:496:EventHandler:<video_enc> encoder got error: Bad parameter (0x80001005)
0:00:00.670008541  3124       0x63a370 ERROR                    omx gstomx.c:268:gst_omx_component_handle_messages:<video_enc> encoder got error: Bad parameter (0x80001005)
0:00:00.670042291  3124       0x63a370 ERROR                    omx gstomx.c:1285:gst_omx_port_acquire_buffer:<video_enc> Component encoder is in error state: Bad parameter
eglSwapBuffers_wrapper---: 1
frame = 1
eglSwapBuffers_wrapper---: 1
frame = 2
eglSwapBuffers_wrapper---: 1
frame = 3
eglSwapBuffers_wrapper---: 0
frame = 4
eglSwapBuffers_wrapper---: 0
frame = 5
eglSwapBuffers_wrapper---: 0
frame = 6
eglSwapBuffers_wrapper---: 0
.
.
.
Using launch string: nveglstreamsrc name=egl_src ! video/x-raw(memory:NVMM), format=I420, width=1280, height=720, framerate=30/1 ! nvegltransform ! nveglglessink
NVEGLStreamProducer: start_eglstream_producer ++
eglDisplay Handle created 
EGLStream initialized
NVEGLStreamProducer: start_eglstream_producer --
display 0x6387b0, stream 0x65b2f1
Thread created

Using winsys: x11 
Obtained EGLConfig and EGLContext
Bound layer to rendering surface
eglSwapBuffers_wrapper---: 1
Not supported input Rmsurface 
0:00:00.637978333  3033       0x634d90 ERROR         nvegltransform gstnvegltransform.c:286:gst_nvegl_transform_transform:<nvegltransform0> can't blit surface to EGLImage.
eglSwapBuffers_wrapper---: 1
frame = 1
eglSwapBuffers_wrapper---: 1
frame = 2
eglSwapBuffers_wrapper---: 1
frame = 3
eglSwapBuffers_wrapper---: 1
frame = 4
eglSwapBuffers_wrapper---: 0
frame = 5
eglSwapBuffers_wrapper---: 0
frame = 6
.
.
.

Hi,
On r28.2/TX1, r28.2.1/TX2, please follow the steps:

  1. Modify CUDA revision in Makefile:
    https://github.com/DaneLLL/simpleEGLStreams_producer
CUDA_PATH ?= /usr/local/cuda-9.0
  1. Modify gstreamer pipeline:
    https://github.com/DaneLLL/gstreamer_eglstreamsrc
launch_stream
    << "nveglstreamsrc name=egl_src ! "
    << "video/x-raw(memory:NVMM), <b>format=RGBA</b>, width="<< w <<", height="<< h <<", framerate=30/1 ! "
    <b><< "nvvidconv ! video/x-raw(memory:NVMM),format=NV12 ! "</b>
    << "omxh264enc bitrate=2500000 name=video_enc iframeinterval=15 profile=high low-latency=false control-rate=4 ! queue ! "
    << "video/x-h264, stream-format=byte-stream  ! "
    << "filesink location=test.264 ";
  1. Replace attached libgstnveglstreamsrc.so
  2. Follow README to build libnveglstreamproducer.so and test app

libgstnveglstreamsrc.zip (12.8 KB)

Cool DaneLLL! Thank you very much! And I also modified this code to stream an NV12 image source generated by VisionWorks, everything works correctly!
Now there is a new question. I add tee to my gst app pipeline as you said in another topic:

launch_stream
	<< "nveglstreamsrc name=egl_src ! "
	<< "video/x-raw(memory:NVMM), format=NV12, width="<< w <<", height="<< h <<", framerate=30/1 ! tee name=t "
	<< "t. ! queue ! omxh264enc insert-sps-pps=true control-rate=3 ! rtph264pay ! "
	<< "udpsink host=192.168.1.33 port=5000 sync=false "
	<< "t. ! queue ! nvegltransform ! nveglglessink ";

Is there any extra memory copy (CPU-GPU) at tee? Thanks again.

No, there is no extra memory copy.

Cheers!