Tk1 Encoder (OMX.Nvidia.h264.encoder) bitrate rate mode

Hi,

I want to know, whether, constant bitrate rate (CBR) mode is supported in TK Hardware encoder (OMX.Nvidia.h264.encoder).

If so how can I set the bitrate mode to CBR. Below is the output GST inspect.

ubuntu@tegra-ubuntu:~$ gst-inspect-0.10 nv_omx_h264enc
Factory Details:
  Long name:    OpenMAX IL H.264/AVC video encoder
  Class:        Codec/Encoder/Video
  Description:  Encodes video in H.264/AVC format with OpenMAX IL
  Author(s):    Felipe Contreras
  Rank:         primary + 10 (266)

Plugin Details:
  Name:                 omx
  Description:          OpenMAX IL
  Filename:             /usr/lib/arm-linux-gnueabihf/gstreamer-0.10/libgstomx.so
  Version:              0.10.1
  License:              LGPL
  Source module:        gst-openmax
  Binary package:       gst-openmax source release
  Origin URL:           Unknown package origin

GObject
 +----GstObject
       +----GstElement
             +----GstOmxBaseFilter
                   +----GstOmxBaseVideoEnc
                         +----GstOmxH264Enc

Implemented Interfaces:
  GstImplementsInterface
  GstOmx

Pad Templates:
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-raw-yuv
                  width: [ 16, 4096 ]
                 height: [ 16, 4096 ]
              framerate: [ 0/1, 2147483647/1 ]
                 format: { I420, NV12 }
      video/x-nv-yuv
                  width: [ 16, 4096 ]
                 height: [ 16, 4096 ]
              framerate: [ 0/1, 2147483647/1 ]
                 format: { I420, NV12 }
      video/x-nvrm-yuv
                  width: [ 16, 4096 ]
                 height: [ 16, 4096 ]
              framerate: [ 0/1, 2147483647/1 ]
                 format: { I420, NV12 }

  SRC template: 'src'
    Availability: Always
    Capabilities:
      video/x-h264
              framerate: [ 0/1, 2147483647/1 ]
                  width: [ 176, 2147483647 ]
                 height: [ 144, 2147483647 ]
          stream-format: { byte-stream, avc }
              alignment: { au }

Element Flags:
  no flags set

Element Implementation:
  Has change_state() function: 0xb6066694
  Has custom save_thyself() function: gst_element_save_thyself
  Has custom restore_thyself() function: gst_element_restore_thyself

Element has no clocking capabilities.
Element has no indexing capabilities.
Element has no URI handling capabilities.

Pads:
  SRC: 'src'
    Implementation:
      Has custom eventfunc(): gst_pad_event_default
      Has custom queryfunc(): gst_pad_query_default
      Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default
      Has getcapsfunc(): gst_pad_get_fixed_caps_func
      Has acceptcapsfunc(): gst_pad_acceptcaps_default
    Pad Template: 'src'
  SINK: 'sink'
    Implementation:
      Has chainfunc(): 0xb606697c
      Has custom eventfunc(): 0xb6065d50
      Has custom queryfunc(): gst_pad_query_default
      Has custom iterintlinkfunc(): gst_pad_iterate_internal_links_default
      Has setcapsfunc(): 0xb608ed24
      Has acceptcapsfunc(): gst_pad_acceptcaps_default
    Pad Template: 'sink'

Element Properties:
  name                : The name of the object
                        flags: readable, writable
                        String. Default: "omxh264enc0"
  component-name      : Name of the OpenMAX IL component to use
                        flags: readable
                        String. Default: "OMX.Nvidia.h264.encoder"
  component-role      : Role of the OpenMAX IL component
                        flags: readable
                        String. Default: null
  library-name        : Name of the OpenMAX IL implementation library to use
                        flags: readable
                        String. Default: "libnvomx.so"
  use-timestamps      : Whether or not to use timestamps
                        flags: readable, writable
                        Boolean. Default: true
  input-buffers       : The number of OMX input buffers
                        flags: readable, writable
                        Unsigned Integer. Range: 1 - 10 Default: 6 
  output-buffers      : The number of OMX output buffers
                        flags: readable, writable
                        Unsigned Integer. Range: 1 - 10 Default: 6 
  full-frame          : Whether or not the data is full framed
                        flags: readable, writable
                        Boolean. Default: true
  bitrate             : Encoding bit-rate
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4294967295 Default: 4000000 
  quality-level       : Encoding quality-level
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 2 Default: 2 
  rc-mode             : Encoding rate control mode
                        flags: readable, writable
                        Enum "GstOmxVideoEncRCModeType" Default: 2, "vbr2"
                           (0): cbr              - GST_OMX_VIDENC_RCMODE_TYPE_CONSTANT
                           (1): vbr              - GST_OMX_VIDENC_RCMODE_TYPE_VARIABLE
                           (2): vbr2             - GST_OMX_VIDENC_RCMODE_TYPE_VARIABLE2
  iframeinterval      : Encoding Intra Frame occurance frequency
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4294967295 Default: 60 
  qp-range            : Qunatization range for P and I frame
                        flags: readable, writable
                        String. Default: null
  temporal-tradeoff   : Temporal Tradeoff value for encoder
                        flags: readable, writable
                        Enum "GstOmxVideoEncTemporalTradeoffType" Default: 0, "30fps"
                           (0): 30fps            - GST_OMX_VIDENC_FORCE_FRAMERATE_AS_FAST_AS_POSSIBLE
                           (1): 24fps            - GST_OMX_VIDENC_FORCE_FRAMERATE_24
                           (2): 20fps            - GST_OMX_VIDENC_FORCE_FRAMERATE_20
                           (3): 15fps            - GST_OMX_VIDENC_FORCE_FRAMERATE_15
                           (4): 10fps            - GST_OMX_VIDENC_FORCE_FRAMERATE_10
  bit-packetization   : Whether or not Packet size is based upon Number Of bits
                        flags: readable, writable
                        Boolean. Default: false
  insert-spsppsatidr  : Whether or not insert SPS & PPS at every IDR
                        flags: readable, writable
                        Boolean. Default: true
  framerate           : Frames per second
                        flags: readable, writable
                        Integer. Range: 0 - 60 Default: 30 
  slice-header-spacing: Slice Header Spacing number of macroblocks/bits in one packet
                        flags: readable, writable
                        Unsigned Long. Range: 0 - 4294967295 Default: 0 

Element Actions:
  "force-IDR" :  void user_function (GstElement* object);

Is it " rc-mode" here means, bitrate mode? Though I set bitrate mode to GST_OMX_VIDENC_RCMODE_TYPE_CONSTANT, I am not getting constant bit rate from the encoder. I am getting variable bit rate only.

Hi Gopinath,
Please try the following command via gstreamer-1.0

gst-launch-1.0 videotestsrc num-buffers=90 ! 'video/x-raw,width=1280,height=720' ! nvvidconv ! omxh264enc control-rate=2 bitrate=1000000 ! filesink location=a.264

With this I can see the bitrate is ~1Mbps(3212240 bits for 3-second 30-fps source)

-rw-rw-r--  1 ubuntu ubuntu 401530 Feb  2 04:24 a.264