1 /*
2 * Copyright (c) 2000,2001 Fabrice Bellard
3 * Copyright (c) 2006 Luca Abeni
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * Video4Linux2 grab interface
25 *
26 * Part of this file is based on the V4L2 video capture example
27 * (http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html)
28 *
29 * Thanks to Michael Niedermayer for providing the mapping between
30 * V4L2_PIX_FMT_* and AV_PIX_FMT_*
31 */
32
33 #include <stdatomic.h>
34
36 #include <dirent.h>
37
38 #if CONFIG_LIBV4L2
39 #include <libv4l2.h>
40 #endif
41
43
44 #define V4L_ALLFORMATS 3
45 #define V4L_RAWFORMATS 1
46 #define V4L_COMPFORMATS 2
47
48 /**
49 * Return timestamps to the user exactly as returned by the kernel
50 */
51 #define V4L_TS_DEFAULT 0
52 /**
53 * Autodetect the kind of timestamps returned by the kernel and convert to
54 * absolute (wall clock) timestamps.
55 */
57 /**
58 * Assume kernel timestamps are from the monotonic clock and convert to
59 * absolute timestamps.
60 */
61 #define V4L_TS_MONO2ABS 2
62
63 /**
64 * Once the kind of timestamps returned by the kernel have been detected,
65 * the value of the timefilter (NULL or not) determines whether a conversion
66 * takes place.
67 */
68 #define V4L_TS_CONVERT_READY V4L_TS_DEFAULT
69
81
93
102 };
103
107 };
108
110 {
112 struct v4l2_capability cap;
113 int fd;
114 int err;
116
117 #define SET_WRAPPERS(prefix) do { \
118 s->open_f = prefix ## open; \
119 s->close_f = prefix ## close; \
120 s->dup_f = prefix ## dup; \
121 s->ioctl_f = prefix ## ioctl; \
122 s->read_f = prefix ## read; \
123 s->mmap_f = prefix ## mmap; \
124 s->munmap_f = prefix ## munmap; \
125 } while (0)
126
128 #if CONFIG_LIBV4L2
130 #else
133 #endif
134 } else {
136 }
137
138 #define v4l2_open s->open_f
139 #define v4l2_close s->close_f
140 #define v4l2_dup s->dup_f
141 #define v4l2_ioctl s->ioctl_f
142 #define v4l2_read s->read_f
143 #define v4l2_mmap s->mmap_f
144 #define v4l2_munmap s->munmap_f
145
147 flags |= O_NONBLOCK;
148 }
149
151 if (fd < 0) {
155 return err;
156 }
157
158 if (
v4l2_ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0) {
163 }
164
166 fd, cap.capabilities);
167
168 if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
172 }
173
174 if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
176 "The device does not support the streaming I/O method.\n");
179 }
180
181 return fd;
182
185 return err;
186 }
187
189 uint32_t pixelformat)
190 {
192 struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
193 int res = 0;
194
195 fmt.fmt.pix.width = *
width;
196 fmt.fmt.pix.height = *
height;
197 fmt.fmt.pix.pixelformat = pixelformat;
198 fmt.fmt.pix.field = V4L2_FIELD_ANY;
199
200 /* Some drivers will fail and return EINVAL when the pixelformat
201 is not supported (even if type field is valid and supported) */
204
205 if ((*width != fmt.fmt.pix.width) || (*height != fmt.fmt.pix.height)) {
207 "The V4L2 driver changed the video from %dx%d to %dx%d\n",
208 *width, *height, fmt.fmt.pix.width, fmt.fmt.pix.height);
209 *width = fmt.fmt.pix.width;
210 *height = fmt.fmt.pix.height;
211 }
212
213 if (pixelformat != fmt.fmt.pix.pixelformat) {
215 "The V4L2 driver changed the pixel format "
216 "from 0x%08X to 0x%08X\n",
217 pixelformat, fmt.fmt.pix.pixelformat);
219 }
220
221 if (fmt.fmt.pix.field == V4L2_FIELD_INTERLACED) {
223 "The V4L2 driver is using the interlaced mode\n");
225 }
226
227 return res;
228 }
229
231 {
232 int res;
233 v4l2_std_id std;
234
236 if (res < 0)
237 return 0;
238 if (std & V4L2_STD_NTSC)
239 return 0;
240
241 return 1;
242 }
243
244 #if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
246 {
248 struct v4l2_frmsizeenum vfse = { .pixel_format = pixelformat };
249
250 while(!
v4l2_ioctl(s->
fd, VIDIOC_ENUM_FRAMESIZES, &vfse)) {
251 switch (vfse.type) {
252 case V4L2_FRMSIZE_TYPE_DISCRETE:
254 vfse.discrete.width, vfse.discrete.height);
255 break;
256 case V4L2_FRMSIZE_TYPE_CONTINUOUS:
257 case V4L2_FRMSIZE_TYPE_STEPWISE:
259 vfse.stepwise.min_width,
260 vfse.stepwise.max_width,
261 vfse.stepwise.step_width,
262 vfse.stepwise.min_height,
263 vfse.stepwise.max_height,
264 vfse.stepwise.step_height);
265 }
266 vfse.index++;
267 }
268 }
269 #endif
270
272 {
274 struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
275
279
280 vfd.index++;
281
282 if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) &&
286 fmt_name ? fmt_name : "Unsupported",
287 vfd.description);
288 } else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED &&
292 desc ? desc->
name :
"Unsupported",
293 vfd.description);
294 } else {
295 continue;
296 }
297
298 #ifdef V4L2_FMT_FLAG_EMULATED
299 if (vfd.flags & V4L2_FMT_FLAG_EMULATED)
301 #endif
302 #if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
303 list_framesizes(ctx, vfd.pixelformat);
304 #endif
306 }
307 }
308
310 {
311 int ret;
313 struct v4l2_standard standard;
314
316 return;
317
318 for (standard.index = 0; ; standard.index++) {
322 break;
323 } else {
325 return;
326 }
327 }
329 standard.index, (uint64_t)standard.id, standard.name);
330 }
331 }
332
334 {
335 int i, res;
337 struct v4l2_requestbuffers req = {
338 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
340 .memory = V4L2_MEMORY_MMAP
341 };
342
346 return res;
347 }
348
349 if (req.count < 2) {
352 }
358 }
364 }
365
366 for (i = 0; i < req.count; i++) {
367 struct v4l2_buffer buf = {
368 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
369 .index = i,
370 .memory = V4L2_MEMORY_MMAP
371 };
375 return res;
376 }
377
381 "buf_len[%d] = %d < expected frame size %d\n",
384 }
386 PROT_READ | PROT_WRITE, MAP_SHARED,
387 s->
fd, buf.m.offset);
388
392 return res;
393 }
394 }
395
396 return 0;
397 }
398
400 {
401 int res = 0;
402
406 } else {
408 }
409
410 return res;
411 }
412
414 {
415 struct v4l2_buffer buf = { 0 };
416 struct buff_data *buf_descriptor = opaque;
418
419 buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
420 buf.memory = V4L2_MEMORY_MMAP;
421 buf.index = buf_descriptor->
index;
423
425 }
426
427 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
428 static int64_t av_gettime_monotonic(void)
429 {
431 }
432 #endif
433
435 {
437 int64_t now;
438
441 ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 *
AV_TIME_BASE) {
444 return 0;
445 }
446 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
448 now = av_gettime_monotonic();
450 (ts <= now + 1 * AV_TIME_BASE && ts >= now - 10 *
AV_TIME_BASE)) {
454 /* microseconds instead of seconds, MHz instead of Hz */
459 return 0;
460 }
461 }
462 #endif
465 }
466
468 {
470
473 if (r < 0)
475 }
476 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
479 int64_t nowm = av_gettime_monotonic();
483 }
484 #endif
485 return 0;
486 }
487
489 {
491 struct v4l2_buffer buf = {
492 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
493 .memory = V4L2_MEMORY_MMAP
494 };
495 int res;
496
498
499 /* FIXME: Some special treatment might be needed in case of loss of signal... */
500 while ((res =
v4l2_ioctl(s->
fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR));
501 if (res < 0) {
502 if (errno == EAGAIN)
504
508 return res;
509 }
510
514 }
516 // always keep at least one buffer queued
518
519 #ifdef V4L2_BUF_FLAG_ERROR
520 if (buf.flags & V4L2_BUF_FLAG_ERROR) {
522 "Dequeued v4l2 buffer contains corrupted data (%d bytes).\n",
523 buf.bytesused);
524 buf.bytesused = 0;
525 } else
526 #endif
527 {
528 /* CPIA is a compressed format and we don't know the exact number of bytes
529 * used by a frame, so set it here as the driver announces it. */
532
535 "Dequeued v4l2 buffer contains %d bytes, but %d were expected. Flags: 0x%08X.\n",
539 }
540 }
541
542 /* Image is at s->buff_start[buf.index] */
544 /* when we start getting low on queued buffers, fall back on copying data */
546 if (res < 0) {
549 return res;
550 }
552
554 if (res) {
556 return res;
557 }
558 } else {
560
562 pkt->
size = buf.bytesused;
563
565 if (!buf_descriptor) {
566 /* Something went wrong... Since av_malloc() failed, we cannot even
567 * allocate a buffer for memcpying into it
568 */
571
573 }
574 buf_descriptor->
index = buf.index;
575 buf_descriptor->
s =
s;
576
578 buf_descriptor, 0);
584 }
585 }
586 pkt->
pts = buf.timestamp.tv_sec * INT64_C(1000000) + buf.timestamp.tv_usec;
588
590 }
591
593 {
595 enum v4l2_buf_type
type;
596 int i, res;
597
598 for (i = 0; i < s->
buffers; i++) {
599 struct v4l2_buffer buf = {
600 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
601 .index = i,
602 .memory = V4L2_MEMORY_MMAP
603 };
604
609 return res;
610 }
611 }
613
614 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
619 return res;
620 }
621
622 return 0;
623 }
624
626 {
627 enum v4l2_buf_type
type;
628 int i;
629
630 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
631 /* We do not check for the result, because we could
632 * not do anything about it anyway...
633 */
635 for (i = 0; i < s->
buffers; i++) {
637 }
640 }
641
643 {
645 struct v4l2_standard standard = { 0 };
646 struct v4l2_streamparm streamparm = { 0 };
647 struct v4l2_fract *tpf;
649 int i, ret;
650
655 return ret;
656 }
657
660 ret = 0;
662 /* set tv standard */
663 for (i = 0; ; i++) {
664 standard.index = i;
667 break;
668 }
670 break;
671 }
672 if (ret < 0) {
674 return ret;
675 }
676
677 if (
v4l2_ioctl(s->
fd, VIDIOC_S_STD, &standard.id) < 0) {
680 return ret;
681 }
682 } else {
684 "This device does not support any standard\n");
685 }
686 }
687
688 /* get standard */
690 tpf = &standard.frameperiod;
691 for (i = 0; ; i++) {
692 standard.index = i;
696 #ifdef ENODATA
698 #endif
699 ) {
700 tpf = &streamparm.parm.capture.timeperframe;
701 break;
702 }
704 return ret;
705 }
706 if (standard.id == s->
std_id) {
708 "Current standard: %s, id: %"PRIx64", frameperiod: %d/%d\n",
709 standard.name, (uint64_t)standard.id, tpf->numerator, tpf->denominator);
710 break;
711 }
712 }
713 } else {
714 tpf = &streamparm.parm.capture.timeperframe;
715 }
716
717 streamparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
718 if (
v4l2_ioctl(s->
fd, VIDIOC_G_PARM, &streamparm) < 0) {
721 }
else if (framerate_q.
num && framerate_q.
den) {
722 if (streamparm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) {
723 tpf = &streamparm.parm.capture.timeperframe;
724
726 framerate_q.
den, framerate_q.
num);
727 tpf->numerator = framerate_q.
den;
728 tpf->denominator = framerate_q.
num;
729
730 if (
v4l2_ioctl(s->
fd, VIDIOC_S_PARM, &streamparm) < 0) {
734 return ret;
735 }
736
737 if (framerate_q.
num != tpf->denominator ||
738 framerate_q.
den != tpf->numerator) {
740 "The driver changed the time per frame from "
741 "%d/%d to %d/%d\n",
742 framerate_q.
den, framerate_q.
num,
743 tpf->numerator, tpf->denominator);
744 }
745 } else {
747 "The driver does not permit changing the time per frame\n");
748 }
749 }
750 if (tpf->denominator > 0 && tpf->numerator > 0) {
754 } else
756
757 return 0;
758 }
759
764 uint32_t *desired_format,
766 {
767 int ret, i;
768
770
771 if (*desired_format) {
772 ret =
device_init(ctx, width, height, *desired_format);
773 if (ret < 0) {
774 *desired_format = 0;
776 return ret;
777 }
778 }
779
780 if (!*desired_format) {
787
789 ret =
device_init(ctx, width, height, *desired_format);
790 if (ret >= 0)
791 break;
792 else if (ret !=
AVERROR(EINVAL))
793 return ret;
794 *desired_format = 0;
795 }
796 }
797
798 if (*desired_format == 0) {
800 "codec '%s' (id %d), pixel format '%s' (id %d)\n",
804 }
805 }
806
809 return ret;
810 }
811
813 {
816 return 0;
817 }
818
820 {
823 int res = 0;
824 uint32_t desired_format;
827 struct v4l2_input input = { 0 };
828
830 if (!st)
832
833 #if CONFIG_LIBV4L2
834 /* silence libv4l2 logging. if fopen() fails v4l2_log_file will be NULL
835 and errors will get sent to stderr */
837 v4l2_log_file = fopen("/dev/null", "w");
838 #endif
839
843
845 /* set video input */
851 }
852 } else {
853 /* get current video input */
858 }
859 }
860
861 /* enum input */
867 }
869 av_log(ctx,
AV_LOG_DEBUG,
"Current input_channel: %d, input_name: %s, input_std: %"PRIx64
"\n",
870 s->
channel, input.name, (uint64_t)input.std);
871
876 }
877
882 }
883
885
888
889 if (codec)
891
893
897
900 }
901 }
902
904 struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
905
907 "Querying the device for the current frame size\n");
913 }
914
915 s->
width = fmt.fmt.pix.width;
916 s->
height = fmt.fmt.pix.height;
918 "Setting frame size to %dx%d\n", s->
width, s->
height);
919 }
920
922 if (res < 0)
924
925 /* If no pixel_format was specified, the codec_id was not known up
926 * until now. Set video_codec_id in the context, as codec_id will
927 * not be available outside this function
928 */
931
934
936
939
944
948
950
958 }
959 if (desired_format == V4L2_PIX_FMT_YVU420)
961 else if (desired_format == V4L2_PIX_FMT_YVU410)
967
968 return 0;
969
972 return res;
973 }
974
976 {
977 #if FF_API_CODED_FRAME && FF_API_LAVF_AVCTX
982 #endif
983 int res;
984
986 return res;
987 }
988
989 #if FF_API_CODED_FRAME && FF_API_LAVF_AVCTX
994 }
996 #endif
997
999 }
1000
1002 {
1004
1007 "close.\n");
1008
1010
1012 return 0;
1013 }
1014
1016 {
1017 return !strncmp(name, "video", 5) ||
1018 !strncmp(name, "radio", 5) ||
1019 !strncmp(name, "vbi", 3) ||
1020 !strncmp(name, "v4l-subdev", 10);
1021 }
1022
1024 {
1026 DIR *dir;
1027 struct dirent *entry;
1029 struct v4l2_capability cap;
1030 int ret = 0;
1031
1032 if (!device_list)
1034
1035 dir = opendir("/dev");
1036 if (!dir) {
1039 return ret;
1040 }
1041 while ((entry = readdir(dir))) {
1043 continue;
1044
1047 continue;
1048
1053 }
1054
1056 if (!device) {
1059 }
1065 }
1066
1070
1073 continue;
1074
1076 if (device) {
1080 }
1084 break;
1085 }
1086 closedir(dir);
1087 return ret;
1088 }
1089
1090 #define OFFSET(x) offsetof(struct video_data, x)
1091 #define DEC AV_OPT_FLAG_DECODING_PARAM
1092
1100
1101 {
"list_formats",
"list available formats and exit",
OFFSET(list_format),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
DEC,
"list_formats" },
1105
1106 {
"list_standards",
"list supported standards and exit",
OFFSET(list_standard),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1,
DEC,
"list_standards" },
1107 {
"all",
"show all supported standards",
OFFSET(list_standard),
AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0,
DEC,
"list_standards" },
1108
1109 {
"timestamps",
"set type of timestamps for grabbed frames",
OFFSET(ts_mode),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2,
DEC,
"timestamps" },
1110 {
"ts",
"set type of timestamps for grabbed frames",
OFFSET(ts_mode),
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2,
DEC,
"timestamps" },
1114 {
"use_libv4l2",
"use libv4l2 (v4l-utils) conversion functions",
OFFSET(use_libv4l2),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
DEC },
1116 };
1117
1124 };
1125
1127 .
name =
"video4linux2,v4l2",
1137 };
int(* open_f)(const char *file, int oflag,...)
Structure describes basic parameters of the device.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
This structure describes decoded (raw) audio or video data.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
#define atomic_store(object, desired)
ptrdiff_t const GLvoid * data
ssize_t(* read_f)(int fd, void *buffer, size_t n)
char * device_description
human friendly name
static int device_init(AVFormatContext *ctx, int *width, int *height, uint32_t pixelformat)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
char * pixel_format
Set by a private option.
char * device_name
device name, format depends on device
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
static int enqueue_buffer(struct video_data *s, struct v4l2_buffer *buf)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int device_try_init(AVFormatContext *ctx, enum AVPixelFormat pix_fmt, int *width, int *height, uint32_t *desired_format, enum AVCodecID *codec_id)
static void list_formats(AVFormatContext *ctx, int type)
uint32_t ff_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id)
double ff_timefilter_eval(TimeFilter *self, double delta)
Evaluate the filter at a specified time.
const struct fmt_map ff_fmt_conversion_table[]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define V4L_TS_ABS
Autodetect the kind of timestamps returned by the kernel and convert to absolute (wall clock) timesta...
Opaque type representing a time filter state.
static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
static int init_convert_timestamp(AVFormatContext *ctx, int64_t ts)
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt)
Return a value representing the fourCC code associated to the pixel format pix_fmt, or 0 if no associated fourCC code can be found.
enum AVStreamParseType need_parsing
static int v4l2_read_header(AVFormatContext *ctx)
static int mmap_start(AVFormatContext *ctx)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
static const int desired_video_buffers
int flags
Flags modifying the (de)muxer behaviour.
static int v4l2_is_v4l_dev(const char *name)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_LOG_VERBOSE
Detailed information.
int interlaced_frame
The content of the picture is interlaced.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
#define V4L_TS_DEFAULT
Return timestamps to the user exactly as returned by the kernel.
static int v4l2_set_parameters(AVFormatContext *ctx)
static int device_open(AVFormatContext *ctx)
enum AVCodecID video_codec_id
Forced video codec_id.
static int first_field(const struct video_data *s)
#define V4L_TS_CONVERT_READY
Once the kind of timestamps returned by the kernel have been detected, the value of the timefilter (N...
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_list)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define atomic_load(object)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const AVOption options[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVMediaType codec_type
General type of the encoded data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVDeviceInfo ** devices
list of autodetected devices
static const uint8_t offset[127][2]
AVRational avg_frame_rate
Average framerate.
#define V4L_TS_MONO2ABS
Assume kernel timestamps are from the monotonic clock and convert to absolute timestamps.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
char filename[1024]
input or output filename
#define AV_TIME_BASE
Internal time base represented as integer.
static void list_standards(AVFormatContext *ctx)
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static int convert_timestamp(AVFormatContext *ctx, int64_t *ts)
static void mmap_close(struct video_data *s)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
int list_format
Set by a private option.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int64_t av_gettime(void)
Get the current time in microseconds.
#define SET_WRAPPERS(prefix)
#define atomic_fetch_add(object, operand)
#define AV_LOG_INFO
Standard information.
TimeFilter * ff_timefilter_new(double time_base, double period, double bandwidth)
Create a new Delay Locked Loop time filter.
char * av_strdup(const char *s)
Duplicate a string.
atomic_int buffers_queued
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Describe the class of an AVClass context structure.
static int v4l2_read_close(AVFormatContext *ctx)
Rational number (pair of numerator and denominator).
const char * name
Name of the codec described by this descriptor.
offset must point to two consecutive integers
This structure contains the data a format has to probe a file.
int list_standard
Set by a private option.
static int mmap_init(AVFormatContext *ctx)
This struct describes the properties of a single codec described by an AVCodecID. ...
static const AVClass v4l2_class
static int v4l2_read_packet(AVFormatContext *ctx, AVPacket *pkt)
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
double ff_timefilter_update(TimeFilter *self, double system_time, double period)
Update the filter.
#define FF_DISABLE_DEPRECATION_WARNINGS
char * framerate
Set by a private option.
channel
Use these values when setting the channel map with ebur128_set_channel().
enum AVCodecID ff_fmt_v4l2codec(uint32_t v4l2_fmt)
#define FF_ENABLE_DEPRECATION_WARNINGS
int top_field_first
If the content is interlaced, is top field displayed first.
void * priv_data
Format private data.
enum AVPixelFormat ff_fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id)
AVInputFormat ff_v4l2_demuxer
static void mmap_release_buffer(void *opaque, uint8_t *data)
AVCodecParameters * codecpar
#define av_malloc_array(a, b)
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int(* munmap_f)(void *_start, size_t length)
static int v4l2_read_probe(AVProbeData *p)
#define MKTAG(a, b, c, d)
AVRational r_frame_rate
Real base framerate of the stream.
int nb_devices
number of autodetected devices
AVPixelFormat
Pixel format.
This structure stores compressed data.
int(* ioctl_f)(int fd, unsigned long int request,...)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...