[FFmpeg-user] h264_v4l2m2m Failed to set gop size: Invalid argument

Ram Shaffir ram at ram.sh
Tue Dec 15 09:54:22 EET 2020


> The problem now is that only the first part file '1-output.ts' is playable, the
> other parts, '2-output.ts' and onwards, are not playable when using ffplay:


I've told that to fix the problem I'm facing with the V4L2 H264 encoder (repeat headers), I should enable V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER in the call v4l2_set_ext_ctrl (https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/v4l2_m2m_enc.c#L53) 

Does it mean that I need to add it like this and recompile?:

static inline int v4l2_get_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int *value, const char *name, int log_warning)
{
    struct v4l2_ext_controls ctrls = { { 0 } };
    struct v4l2_ext_control ctrl = { 0 };
    int ret;

    /* like this? */
    V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER = 1;

    /* set ctrls */
    ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
    ctrls.controls = &ctrl;
    ctrls.count = 1;

    /* set ctrl*/
    ctrl.id = id ;

    ret = ioctl(s->fd, VIDIOC_G_EXT_CTRLS, &ctrls);
    if (ret < 0) {
        av_log(s->avctx, log_warning || errno != EINVAL ? AV_LOG_WARNING : AV_LOG_DEBUG,
               "Failed to get %s\n", name);
        return ret;
    }

    *value = ctrl.value;

    return 0;
}


More information about the ffmpeg-user mailing list