Gstreamer encode h.264 got frame drops,can not support 1080p@60fps

I have a MIPI CSI-2 camera which output UYVY format @1080p 60fps.

h.264 encoder can not achieve 60fps

I use this gstreamer cmd and only got 30-32fps.

gst-launch-1.0 v4l2src num-buffers=300 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080,framerate=(fraction)60/1" ! videoconvert ! omxh264enc ! matroskamux ! filesink location=videoname.mkv

Also tried nvv4l2h264enc encoder which got same result.

I post gstreamer debug info, hope will help:

export GST_DEBUG="*:3"
gst-launch-1.0 v4l2src num-buffers=300 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080,framerate=(fraction)60/1" ! videoconvert ! omxh264enc ! matroskamux ! filesink location=videoname.mkv
0:00:00.084741262  9786   0x55a7757870 WARN                     omx gstomx.c:2826:plugin_init: Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /home/xumm/.config:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
0:00:00.120136552  9786   0x55a77c3800 FIXME           videoencoder gstvideoencoder.c:661:gst_video_encoder_setcaps:<omxh264enc-omxh264enc0> GstVideoEncoder::reset() is deprecated
Framerate set to : 60 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
0:00:00.123010972  9786   0x55a77c3800 WARN             omxvideoenc gstomxvideoenc.c:1860:gst_omx_video_enc_set_format:<omxh264enc-omxh264enc0> Error setting temporal_tradeoff 0 : Vendor specific error (0x00000001)
H264: Profile = 66, Level = 40 
0:00:00.401167094  9786   0x55a77c3800 WARN                 v4l2src gstv4l2src.c:911:gst_v4l2src_create:<v4l2src0> Timestamp does not correlate with any clock, ignoring driver timestamps
NVMEDIA_ENC: bBlitMode is set to TRUE 
0:00:00.458222133  9786   0x7f700044f0 FIXME               basesink gstbasesink.c:3145:gst_base_sink_default_event:<filesink0> stream-start event without group-id. Consider implementing group-id handling in the upstream elements
Got EOS from element "pipeline0".
Execution ended after 0:00:08.853691203
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

difference between nvvidconv and videoconvert

nvvidconv output 28fps

gst-launch-1.0 v4l2src ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080,framerate=(fraction)60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=(string)I420,framerate=(fraction)60/1" ! fpsdisplaysink video-sink=fakesink -v

videoconvert output 60fps

gst-launch-1.0 v4l2src ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080,framerate=(fraction)60/1" ! videoconvert ! fpsdisplaysink video-sink=fakesink -v

I can be sure that the output frame rate of this camera is fine.
Grateful for any help, thanks!

Hi,
Please try the pipeline, and check if you can see preview and achieve target fps:

$ gst-launch-1.0 nvv4l2camerasrc num-buffers=300 ! 'video/x-raw(memory:NVMM),format=(string)UYVY, width=(int)1920, height=(int)1080,framerate=(fraction)60/1' ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! fpsdisplaysink text-overlay=0 video-sink=fakesink sync=0 -v
WARNING: erroneous pipeline: could not link v4l2src0 to nvvconv0, v4l2src0 can't handle caps video/x-raw(memory:NVMM), format=(string)UYVY, width=(int)1920, height=(int)1080, framerate=(fraction)60/1

If I remove (memory:NVMM),use

gst-launch-1.0 v4l2src device=/dev/video0 ! "video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080,framerate=(fraction)60/1" ! nvvidconv ! "video/x-raw(memory:NVMM),format=NV12" ! fpsdisplaysink text-overlay=0 video-sink=fakesink sync=0 -v

It turns out 28fps. No preview.

Hi,
I have corrected a typo in the command. Please run with nvv4l2camerasrc.

Hi,
Thank you very much! It works!
Can you tell me if nvv4l2camerasrc can completely replace v4l2src?What are its advantages?
memory:NVMM storage method can help explain?
Thanks again for your prompt and effective reply!

Hi,
NVMM buffer is hardware DMA buffer. Running a gstreamer pipeline to have NVMM buffer from hard to tail eliminates copying data from CPU buffer to NVMM buffer. It is an optimal solution on Jetson platforms.

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