Page 1 of 1

Gstreamer omxh264 decode image is not good

Posted: Sat May 15, 2021 5:00 am
by ngdnam
Dear guys
I used HDMI to USB capture card to stream monitor of pc on network by using gstreamer.

1st, I try to use x264 to encode and stream with this command
$ ./test-launch "v4l2src device=/dev/video0 ! videoconvert ! x264enc speed-preset=ultrafast tune=zerolatency ! rtph264pay name=pay0 pt=96"
then using open vlc to open this stream. Image is good but bandwith and bit rate is high.

2nd I want to reduce bandwith and bit rate, then using omxh264 to encode and stream with this command
./test-launch "v4l2src device=/dev/video0 ! video/x-raw, width=1920, height=1080, framerate=5/1, format=YUY2 ! videoconvert ! omxh264enc ! video/x-h264,profile=baseline ! h264parse ! rtph264pay name=pay0 pt=96"
But image is not good when I play by vlc or other rstp player (attached image). Some problem at near under of image.
Can any one suggest the way to resolve?

Re: Gstreamer omxh264 decode image is not good

Posted: Sat May 15, 2021 7:58 pm
by 6by9
Use v4l2h264enc instead of omxh264enc.
Without analysing the pipeline in detail it's hard to say for certain, but I suspect that videoconvert/omxh264nc has failed to notice that OMX needs the image planes need to be padded to multiple of 16 lines (ie 1088 instead of 1080). That error means that the chroma planes will be in the wrong place.

v4l2h264enc can also take YUYV directly without needing videoconvert.
GStreamer may try to use dmabufs to provide a zero copy path from v4l2src to v4l2h264enc, however there are different underlying allocation schemes. The V4L2 encoder requires contiguous buffers, whilst uvcvideo will allocate scattered buffers by default. You may need to set io-mode=2 on v4l2src, and output-io-mode=2 on v4l2h264enc.