/*
* Video4Linux2 grab interface
- * Copyright (c) 2000,2001 Fabrice Bellard.
- * Copyright (c) 2006 Luca Abeni.
+ * Copyright (c) 2000,2001 Fabrice Bellard
+ * Copyright (c) 2006 Luca Abeni
*
* Part of this file is based on the V4L2 video capture example
* (http://v4l2spec.bytesex.org/v4l2spec/capture.c)
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/time.h>
-#ifdef HAVE_SYS_VIDEOIO_H
+#if HAVE_SYS_VIDEOIO_H
#include <sys/videoio.h>
#else
#include <asm/types.h>
int frame_format; /* V4L2_PIX_FMT_* */
enum io_method io_method;
int width, height;
- int frame_rate;
- int frame_rate_base;
int frame_size;
int top_field_first;
int res, fd;
struct buff_data *buf_descriptor = pkt->priv;
+ if (pkt->data == NULL) {
+ return;
+ }
+
memset(&buf, 0, sizeof(struct v4l2_buffer));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
}
av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n",
- ap->standard, standard.id);
+ ap->standard, (uint64_t)standard.id);
if (ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) {
av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
ap->standard);
struct video_data *s = s1->priv_data;
AVStream *st;
int width, height;
- int res, frame_rate, frame_rate_base;
+ int res;
uint32_t desired_format, capabilities;
if (ap->width <= 0 || ap->height <= 0) {
av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", ap->width, ap->height);
return -1;
}
- if (ap->time_base.den <= 0) {
- av_log(s1, AV_LOG_ERROR, "Wrong time base (%d)\n", ap->time_base.den);
- return -1;
- }
width = ap->width;
height = ap->height;
- frame_rate = ap->time_base.den;
- frame_rate_base = ap->time_base.num;
if(avcodec_check_dimensions(s1, ap->width, ap->height) < 0)
return -1;
s->width = width;
s->height = height;
- s->frame_rate = frame_rate;
- s->frame_rate_base = frame_rate_base;
capabilities = 0;
s->fd = device_open(s1, &capabilities);
st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec->width = width;
st->codec->height = height;
- st->codec->time_base.den = frame_rate;
- st->codec->time_base.num = frame_rate_base;
+ st->codec->time_base.den = ap->time_base.den;
+ st->codec->time_base.num = ap->time_base.num;
st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
return 0;