Setting codec parameters on DB820C

Hi,

Does the v4l2h264enc video codec on DB820C currently support setting codec parameters (bitrate, I-frame period etc)?

I tried passing in video_gop_size or h264_i_frame_period via extra-controls but the resultant video only contained 1x I-frame at the start:
gst-launch-1.0 videotestsrc ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1,profile=high ! v4l2h264enc extra-controls="controls,h264_i_frame_period=10,video_gop_size=10" ! queue ! filesink location=/home/linaro/enc.h264

Looking for key frames in the resultant file shows that only the first frame is a key frame:
ffprobe -show_frames enc.h264 | grep key_frame

Similarly using v4l2-ctl to set the parameters then reading them back shows they haven’t taken effect:
root@linaro-alip:/home/linaro# v4l2-ctl -d /dev/video0 --get-ctrl video_gop_size
video_gop_size: 12
root@linaro-alip:/home/linaro# v4l2-ctl -d /dev/video0 --set-ctrl video_gop_size=40
root@linaro-alip:/home/linaro# v4l2-ctl -d /dev/video0 --get-ctrl video_gop_size
video_gop_size: 12

It’s the same for video_bitrate etc. Maybe set-ctrl also doesn’t work on 410C but according to messages in the 410C forum at least extra-controls should work. Are the codec parameters just not supported yet on 820C?

I’ve tried version 222 and 228, plus built my own kernel from the release/qcomlt-4.14 branch, none of them are able to set the I-frame period.

Thanks

Having done some more digging, it appears that the video_gop_size parameter is actually getting through to the Venus driver in the kernel. The Venus encoder is generating I-frames at the requested interval but these are not IDR frames.

/* IDR periodicity, n:

  • n = 0 - only the first I-frame is IDR frame
  • n = 1 - all I-frames will be IDR frames
  • n > 1 - every n-th I-frame will be IDR frame
    */
    ptype = HFI_PROPERTY_CONFIG_VENC_IDR_PERIOD;
    idrp.idr_period = 0;

Setting this to 1 makes all I-frames IDR-frames, and ffprobe then reports key_frame=1 for them.

It looks like the H264 encoder treats video_gop_size and h264_i_frame_period interchangeably (preferring video_gop_size if both are set). But according to the following, GOP_SIZE should specify the period between IDR frames, while h264_i_frame_period should specify the period between I-frames:
http://www.retiisi.org.uk/v4l2/tmp/media_api/extended-controls.html

V4L2_CID_MPEG_VIDEO_H264_I_PERIOD
Period between I-frames in the open GOP for H264. In case of an open GOP this is the period between two I-frames. The period between IDR (Instantaneous Decoding Refresh) frames is taken from the GOP_SIZE control. An IDR frame, which stands for Instantaneous Decoding Refresh is an I-frame after which no prior frames are referenced. This means that a stream can be restarted from an IDR frame without the need to store or decode any previous frames. Applicable to the H264 encoder.