omxh264enc bitrate low and not configurable

hi

In my application, I use the gstreamer element omxh264enc to encode a 3840x1920P30 video stream. The problem is that the bitrate is incorrectly set to 1~1.2Mbps(from observing running result), not 8Mbps as I set with g_object_set, nor 4Mbps as the default.

g_object_set(G_OBJECT(enc), "bitrate", 8000000, NULL);

The above line of code seems unable to configure encoder’s bitrate, no matter what value it’s set. Only when I set the qp-range property, to lower the max boundry to 30, as

g_object_set(G_OBJECT(enc), "qp-range", "0,30:0,30:0,30", NULL);

the bitrate would go up to somewhere 5Mbps.

Then, to compare, I tried this command line

gst-launch-1.0 \
v4l2src device=/dev/video0 ! 'video/x-raw, width=(int)1920, height=(int)1080, format=(string)UYVY, framerate=(fraction)30/1' ! \
nvvidconv ! 'video/x-raw(memory:NVMM), width=(int)3840, height=(int)1920, format=(string)I420, framerate=(fraction)30/1' ! \
omxh264enc bitrate=8000000 ! h264parse ! mp4mux ! filesink location=./rec.mp4

And this time the bitrate is indeed 8Mbps as expected.

So what’s making the bitrate property invalid?

Hi xliu,
Do you configure timestamps correctly in your app? Looks like the frame rate is not 30fps as encoder expects.

hi Dane,

The gstreamer pipeline looks like:

appsrc -> omxh264enc -> h264parse -> mp4mux -> filesink

The video souce is a live source, but since we need to do some custom processing before encoding, we use appsrc. And I did not set timestamps before feeding buffer to the appsrc element. What to do to add timestamps? Current code uses gst_buffer_new_wrapped_full() and gst_app_src_push_buffer() to do the buffer feeding.

The actual framerate is 30fps, I’m sure of this.

hi Dane,

By setting “do-timestamp” of the appsrc, this issue is fixed. Thanks you very much!