Gstreamer 700kbit constant bit rate encoding produces 1499 kbit stream

Hello,

I produce a mpegts stream with the below command and the output stream is around 1500 kbit/s. I would expect it to be around 700kbits since I give the “bitrate=700” option.
I tried removing the “mpegtsmux” option but the output stream dropped to 1300 kbit/s
Can you please guide me about what I am doing wrong?

gst-launch-1.0 imxv4l2src
device=/dev/video0 ! \ imxvpuenc_h264
bitrate=700 ! \ h264parse ! mpegtsmux
! queue ! fdsink | pv > /dev/null

root@colibri-imx6:~# ./pv.sh 14MiB
0:00:07 [ 181kiB/s] [ <=> ]

Below is a picture of the vlc codec info output when I play the file. Note that the background is almost constant.

alt text

hi @rifo

Could you provide the version of the hardware and software of your module?

What is your application? What is the resolution of your video? What is your frame-rate?

Hello,

We are using a (800 TVL) PAL (720 x 576) camera. There is an ADV7280 which converts incoming analog video to paralell. Incoming parallel video data is then H264 encoded, serialized and sent over UART. For the encoding we currently use the command in the first post.
For FPS, VLC shows 25 fps, we use the default settings of ADV7280 driver

We are using a colibri imx6 solo 512 MB IT module with a custom baseboard which has an ADV7280
Here are the software versions

 root@colibri-imx6:~# gst-launch-1.0  --version
gst-launch-1.0 version 1.12.2
GStreamer 1.12.2

root@colibri-imx6:~# gst-inspect-1.0 imxv4l2src
====== IMXV4L2SRC: 4.3.1 build on Jul  3 2018 14:07:07. ======

root@colibri-imx6:~# gst-inspect-1.0  imxvpuenc_h264
Factory Details:
  Rank                     primary + 1 (257)
  Long-name                Freescale VPU h.264 video encoder
  Klass                    Codec/Encoder/Video
  Description              hardware-accelerated h.264 video encoding using the Freescale VPU engine
  Author                   Carlos Rafael Giani <dv@pseudoterminal.org>

Plugin Details:
  Name                     imxvpu
  Description              video en- and decoder elements using the Freescale i.MX VPU
  Filename                 /usr/lib/gstreamer-1.0/libgstimxvpu.so
  Version                  0.13.0
  License                  LGPL
  Source module            gstreamer-imx
  Binary package           Unknown package release
  Origin URL               Unknown package origin

file.ts

I attached the recorded video.

Hi

Thanks for these Information. Actually it will be helpful to have the Linux Kernel Version ( uname ). Did you try setting a different bitrate? Maybe also higher than 1500?

Additionally can you read our developer article about Video in Linux?
Thanks

Hello,

Thanks for the video in linux link. The warning about bitrate option seems to suit our case.
However “imxvpuenc_h264” doesn’t seem to have these extra options.

Element Properties:
  name                : The name of the object
                        flags: readable, writable
                        String. Default: "imxvpuencoderh264-0"
  parent              : The parent of the object
                        flags: readable, writable
                        Object of type "GstObject"
  drop                : Drop frames
                        flags: readable, writable
                        Boolean. Default: false
  gop-size            : How many frames a group-of-picture shall contain
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 32767 Default: 16 
  bitrate             : Bitrate to use, in kbps (0 = no bitrate control; constant quality mode is used)
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4294967295 Default: 0 
  slice-size          : Maximum slice size (0 = unlimited, <0 in MB, >0 in bits)
                        flags: readable, writable
                        Integer. Range: -2147483648 - 2147483647 Default: 0 
  intra-refresh       : Minimum number of MBs to encode as intra MB
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4294967295 Default: 0 
  me-search-range     : Search range for motion estimation
                        flags: readable, writable
                        Enum "ImxVpuEncMESearchRanges" Default: 0, "256x128"
                           (0): 256x128          - 256x128 blocks
                           (1): 128x64           - 128x64 blocks
                           (2): 64x32            - 64x32 blocks
                           (3): 32x32            - 32x32 blocks
  quant-param         : Constant quantization quality parameter (ignored if bitrate is set to a nonzero value)
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 51 Default: 0 
  idr-interval        : Interval between IDR frames
                        flags: readable, writable
                        Unsigned Integer. Range: 0 - 4294967295 Default: 0 

Am I missing something?

Also below are the uname and 1600 kbit/second encoding outputs. Again, imxvpuenc_h264 seems to produce double the expected bitrate

root@colibri-imx6:~# uname -a
Linux colibri-imx6 4.9.84-2.8.2+gb2a7f2f #2 SMP Tue Jul 3 14:03:30 +03 2018 armv7l GNU/Linux

root@colibri-imx6:~# ./pv.sh 
^C.9MiB 0:00:08 [ 408kiB/s] [        <=>         ]

thanks for your help

I have added an issue to Freescale/gstreamer-imx repo:

didn’t check the frame rate correctly.
ADV7280 was outputting 50 fps. Dropped half of it and the bitrate is in accordance with the input target bitrate

Perfect that it works. Thanks for your feedback.