aboutsummaryrefslogtreecommitdiff
path: root/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'video.c')
-rw-r--r--video.c88
1 files changed, 43 insertions, 45 deletions
diff --git a/video.c b/video.c
index 3440390..e6f9a58 100644
--- a/video.c
+++ b/video.c
@@ -84,73 +84,71 @@ int video_set_control(struct instance *i)
parm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
parm.parm.output.timeperframe.numerator = 1;
- parm.parm.output.timeperframe.denominator = 30;
+ if (i->framerate <= 30 && i->framerate >= 1)
+ parm.parm.output.timeperframe.denominator = i->framerate;
+ else
+ parm.parm.output.timeperframe.denominator = 30;
+
+ info("setting framerate: %u", i->framerate);
- info("setting framerate");
ret = ioctl(i->video.fd, VIDIOC_S_PARM, &parm);
if (ret)
err("set framerate (%s)", strerror(errno));
cntrl.id = V4L2_CID_MPEG_VIDEO_BITRATE;
- cntrl.value = 10 * 1024 * 1024;
+ if (i->bitrate <= 160000000 && i->bitrate >= 32000)
+ cntrl.value = i->bitrate;
+ else
+ cntrl.value = 10 * 1024 * 1024;
info("setting bitrate: %u", cntrl.value);
- ret = ioctl(i->video.fd, VIDIOC_S_CTRL, &cntrl);
- if (ret)
- err("set control - bitrate (%s)", strerror(errno));
-
- cntrl.id = V4L2_CID_MPEG_VIDC_VIDEO_H264_VUI_TIMING_INFO;
- cntrl.value = V4L2_MPEG_VIDC_VIDEO_H264_VUI_TIMING_INFO_ENABLED;
ret = ioctl(i->video.fd, VIDIOC_S_CTRL, &cntrl);
if (ret)
- err("set control - vui timing info (%s)", strerror(errno));
+ err("set control - bitrate (%s)", strerror(errno));
- {
- struct v4l2_ext_controls ctrls;
- struct v4l2_ext_control ctrl[32];
- int c = 0;
+ struct v4l2_ext_controls ctrls;
+ struct v4l2_ext_control ctrl[32];
+ int c = 0;
- memset (&ctrls, 0, sizeof(ctrls));
- ctrls.controls = ctrl;
- ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
+ memset (&ctrls, 0, sizeof(ctrls));
+ ctrls.controls = ctrl;
+ ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
- ctrl[c].id = V4L2_CID_MPEG_VIDEO_H264_PROFILE;
- ctrl[c].value = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH;
- c++;
+ ctrl[c].id = V4L2_CID_MPEG_VIDEO_H264_PROFILE;
+ ctrl[c].value = V4L2_MPEG_VIDEO_H264_PROFILE_HIGH;
+ c++;
- ctrl[c].id = V4L2_CID_MPEG_VIDEO_H264_LEVEL;
- ctrl[c].value = V4L2_MPEG_VIDEO_H264_LEVEL_5_0;
- c++;
+ ctrl[c].id = V4L2_CID_MPEG_VIDEO_H264_LEVEL;
+ ctrl[c].value = V4L2_MPEG_VIDEO_H264_LEVEL_5_0;
+ c++;
-// ctrl[c].id = V4L2_CID_MPEG_VIDEO_BITRATE_MODE;
-// ctrl[c].value = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
-// c++;
+ ctrl[c].id = V4L2_CID_MPEG_VIDEO_BITRATE_MODE;
+ ctrl[c].value = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
+ c++;
- ctrl[c].id = V4L2_CID_MPEG_VIDEO_GOP_SIZE;
- ctrl[c].value = 1;
- c++;
+ ctrl[c].id = V4L2_CID_MPEG_VIDEO_GOP_SIZE;
+ ctrl[c].value = 1;
+ c++;
- /* intra_period = pframes + bframes + 1
- * bframes/pframes must be integer
- *
- */
+ /*
+ * intra_period = pframes + bframes + 1
+ * bframes/pframes must be integer
+ */
- ctrl[c].id = V4L2_CID_MPEG_VIDEO_B_FRAMES;
- ctrl[c].value = 0;
- c++;
+ ctrl[c].id = V4L2_CID_MPEG_VIDEO_B_FRAMES;
+ ctrl[c].value = 0;
+ c++;
- ctrl[c].id = V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES;
- ctrl[c].value = 29;//2 * 15 - 1;
- c++;
+// ctrl[c].id = V4L2_CID_MPEG_VIDC_VIDEO_NUM_P_FRAMES;
+// ctrl[c].value = 2 * 15 - 1;
+// c++;
- ctrls.count = c;
+ ctrls.count = c;
- ret = ioctl(i->video.fd, VIDIOC_S_EXT_CTRLS, &ctrls);
- if (ret)
- err("set ext control - profile/level (%s)",
- strerror(errno));
- }
+ ret = ioctl(i->video.fd, VIDIOC_S_EXT_CTRLS, &ctrls);
+ if (ret)
+ err("set ext controls (%s)", strerror(errno));
return 0;
}