Statistics
| Branch: | Revision:

ffmpeg / libavdevice / v4l2.c @ 97a290ef

History | View | Annotate | Download (17.1 KB)

1
/*
2
 * Video4Linux2 grab interface
3
 * Copyright (c) 2000,2001 Fabrice Bellard.
4
 * Copyright (c) 2006 Luca Abeni.
5
 *
6
 * Part of this file is based on the V4L2 video capture example
7
 * (http://v4l2spec.bytesex.org/v4l2spec/capture.c)
8
 *
9
 * Thanks to Michael Niedermayer for providing the mapping between
10
 * V4L2_PIX_FMT_* and PIX_FMT_*
11
 *
12
 *
13
 * This file is part of FFmpeg.
14
 *
15
 * FFmpeg is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU Lesser General Public
17
 * License as published by the Free Software Foundation; either
18
 * version 2.1 of the License, or (at your option) any later version.
19
 *
20
 * FFmpeg is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23
 * Lesser General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU Lesser General Public
26
 * License along with FFmpeg; if not, write to the Free Software
27
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28
 */
29

    
30
#undef __STRICT_ANSI__ //workaround due to broken kernel headers
31
#include "config.h"
32
#include "libavformat/avformat.h"
33
#include <unistd.h>
34
#include <fcntl.h>
35
#include <sys/ioctl.h>
36
#include <sys/mman.h>
37
#include <sys/time.h>
38
#include <asm/types.h>
39
#include <linux/videodev2.h>
40
#include <time.h>
41
#include <strings.h>
42

    
43
static const int desired_video_buffers = 256;
44

    
45
enum io_method {
46
    io_read,
47
    io_mmap,
48
    io_userptr
49
};
50

    
51
struct video_data {
52
    int fd;
53
    int frame_format; /* V4L2_PIX_FMT_* */
54
    enum io_method io_method;
55
    int width, height;
56
    int frame_rate;
57
    int frame_rate_base;
58
    int frame_size;
59
    int top_field_first;
60

    
61
    int buffers;
62
    void **buf_start;
63
    unsigned int *buf_len;
64
};
65

    
66
struct buff_data {
67
    int index;
68
    int fd;
69
};
70

    
71
struct fmt_map {
72
    enum PixelFormat ff_fmt;
73
    int32_t v4l2_fmt;
74
};
75

    
76
static struct fmt_map fmt_conversion_table[] = {
77
    {
78
        .ff_fmt = PIX_FMT_YUV420P,
79
        .v4l2_fmt = V4L2_PIX_FMT_YUV420,
80
    },
81
    {
82
        .ff_fmt = PIX_FMT_YUV422P,
83
        .v4l2_fmt = V4L2_PIX_FMT_YUV422P,
84
    },
85
    {
86
        .ff_fmt = PIX_FMT_YUYV422,
87
        .v4l2_fmt = V4L2_PIX_FMT_YUYV,
88
    },
89
    {
90
        .ff_fmt = PIX_FMT_UYVY422,
91
        .v4l2_fmt = V4L2_PIX_FMT_UYVY,
92
    },
93
    {
94
        .ff_fmt = PIX_FMT_YUV411P,
95
        .v4l2_fmt = V4L2_PIX_FMT_YUV411P,
96
    },
97
    {
98
        .ff_fmt = PIX_FMT_YUV410P,
99
        .v4l2_fmt = V4L2_PIX_FMT_YUV410,
100
    },
101
    {
102
        .ff_fmt = PIX_FMT_RGB555,
103
        .v4l2_fmt = V4L2_PIX_FMT_RGB555,
104
    },
105
    {
106
        .ff_fmt = PIX_FMT_RGB565,
107
        .v4l2_fmt = V4L2_PIX_FMT_RGB565,
108
    },
109
    {
110
        .ff_fmt = PIX_FMT_BGR24,
111
        .v4l2_fmt = V4L2_PIX_FMT_BGR24,
112
    },
113
    {
114
        .ff_fmt = PIX_FMT_RGB24,
115
        .v4l2_fmt = V4L2_PIX_FMT_RGB24,
116
    },
117
    /*
118
    {
119
        .ff_fmt = PIX_FMT_RGB32,
120
        .v4l2_fmt = V4L2_PIX_FMT_BGR32,
121
    },
122
    */
123
    {
124
        .ff_fmt = PIX_FMT_GRAY8,
125
        .v4l2_fmt = V4L2_PIX_FMT_GREY,
126
    },
127
};
128

    
129
static int device_open(AVFormatContext *ctx, uint32_t *capabilities)
130
{
131
    struct v4l2_capability cap;
132
    int fd;
133
    int res;
134
    int flags = O_RDWR;
135

    
136
    if (ctx->flags & AVFMT_FLAG_NONBLOCK) {
137
        flags |= O_NONBLOCK;
138
    }
139
    fd = open(ctx->filename, flags, 0);
140
    if (fd < 0) {
141
        av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n",
142
                 ctx->filename, strerror(errno));
143

    
144
        return -1;
145
    }
146

    
147
    res = ioctl(fd, VIDIOC_QUERYCAP, &cap);
148
    // ENOIOCTLCMD definition only availble on __KERNEL__
149
    if (res < 0 && errno == 515)
150
    {
151
        av_log(ctx, AV_LOG_ERROR, "QUERYCAP not implemented, probably V4L device but not supporting V4L2\n");
152
        close(fd);
153

    
154
        return -1;
155
    }
156
    if (res < 0) {
157
        av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n",
158
                 strerror(errno));
159
        close(fd);
160

    
161
        return -1;
162
    }
163
    if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
164
        av_log(ctx, AV_LOG_ERROR, "Not a video capture device\n");
165
        close(fd);
166

    
167
        return -1;
168
    }
169
    *capabilities = cap.capabilities;
170

    
171
    return fd;
172
}
173

    
174
static int device_init(AVFormatContext *ctx, int *width, int *height, int pix_fmt)
175
{
176
    struct video_data *s = ctx->priv_data;
177
    int fd = s->fd;
178
    struct v4l2_format fmt;
179
    int res;
180

    
181
    memset(&fmt, 0, sizeof(struct v4l2_format));
182
    fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
183
    fmt.fmt.pix.width = *width;
184
    fmt.fmt.pix.height = *height;
185
    fmt.fmt.pix.pixelformat = pix_fmt;
186
    fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
187
    res = ioctl(fd, VIDIOC_S_FMT, &fmt);
188
    if ((*width != fmt.fmt.pix.width) || (*height != fmt.fmt.pix.height)) {
189
        av_log(ctx, AV_LOG_INFO, "The V4L2 driver changed the video from %dx%d to %dx%d\n", *width, *height, fmt.fmt.pix.width, fmt.fmt.pix.height);
190
        *width = fmt.fmt.pix.width;
191
        *height = fmt.fmt.pix.height;
192
    }
193

    
194
    return res;
195
}
196

    
197
static int first_field(int fd)
198
{
199
    int res;
200
    v4l2_std_id std;
201

    
202
    res = ioctl(fd, VIDIOC_G_STD, &std);
203
    if (res < 0) {
204
        return 0;
205
    }
206
    if (std & V4L2_STD_NTSC) {
207
        return 0;
208
    }
209

    
210
    return 1;
211
}
212

    
213
static uint32_t fmt_ff2v4l(enum PixelFormat pix_fmt)
214
{
215
    int i;
216

    
217
    for (i = 0; i < sizeof(fmt_conversion_table) / sizeof(struct fmt_map); i++) {
218
        if (fmt_conversion_table[i].ff_fmt == pix_fmt) {
219
            return fmt_conversion_table[i].v4l2_fmt;
220
        }
221
    }
222

    
223
    return 0;
224
}
225

    
226
static enum PixelFormat fmt_v4l2ff(uint32_t pix_fmt)
227
{
228
    int i;
229

    
230
    for (i = 0; i < sizeof(fmt_conversion_table) / sizeof(struct fmt_map); i++) {
231
        if (fmt_conversion_table[i].v4l2_fmt == pix_fmt) {
232
            return fmt_conversion_table[i].ff_fmt;
233
        }
234
    }
235

    
236
    return PIX_FMT_NONE;
237
}
238

    
239
static int mmap_init(AVFormatContext *ctx)
240
{
241
    struct video_data *s = ctx->priv_data;
242
    struct v4l2_requestbuffers req;
243
    int i, res;
244

    
245
    memset(&req, 0, sizeof(struct v4l2_requestbuffers));
246
    req.count = desired_video_buffers;
247
    req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
248
    req.memory = V4L2_MEMORY_MMAP;
249
    res = ioctl (s->fd, VIDIOC_REQBUFS, &req);
250
    if (res < 0) {
251
        if (errno == EINVAL) {
252
            av_log(ctx, AV_LOG_ERROR, "Device does not support mmap\n");
253
        } else {
254
            av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_REQBUFS)\n");
255
        }
256

    
257
        return -1;
258
    }
259

    
260
    if (req.count < 2) {
261
        av_log(ctx, AV_LOG_ERROR, "Insufficient buffer memory\n");
262

    
263
        return -1;
264
    }
265
    s->buffers = req.count;
266
    s->buf_start = av_malloc(sizeof(void *) * s->buffers);
267
    if (s->buf_start == NULL) {
268
        av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer pointers\n");
269

    
270
        return -1;
271
    }
272
    s->buf_len = av_malloc(sizeof(unsigned int) * s->buffers);
273
    if (s->buf_len == NULL) {
274
        av_log(ctx, AV_LOG_ERROR, "Cannot allocate buffer sizes\n");
275
        av_free(s->buf_start);
276

    
277
        return -1;
278
    }
279

    
280
    for (i = 0; i < req.count; i++) {
281
        struct v4l2_buffer buf;
282

    
283
        memset(&buf, 0, sizeof(struct v4l2_buffer));
284
        buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
285
        buf.memory = V4L2_MEMORY_MMAP;
286
        buf.index = i;
287
        res = ioctl (s->fd, VIDIOC_QUERYBUF, &buf);
288
        if (res < 0) {
289
            av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYBUF)\n");
290

    
291
            return -1;
292
        }
293

    
294
        s->buf_len[i] = buf.length;
295
        if (s->buf_len[i] < s->frame_size) {
296
            av_log(ctx, AV_LOG_ERROR, "Buffer len [%d] = %d != %d\n", i, s->buf_len[i], s->frame_size);
297

    
298
            return -1;
299
        }
300
        s->buf_start[i] = mmap (NULL, buf.length,
301
                        PROT_READ | PROT_WRITE, MAP_SHARED, s->fd, buf.m.offset);
302
        if (s->buf_start[i] == MAP_FAILED) {
303
            av_log(ctx, AV_LOG_ERROR, "mmap: %s\n", strerror(errno));
304

    
305
            return -1;
306
        }
307
    }
308

    
309
    return 0;
310
}
311

    
312
static int read_init(AVFormatContext *ctx)
313
{
314
    return -1;
315
}
316

    
317
static void mmap_release_buffer(AVPacket *pkt)
318
{
319
    struct v4l2_buffer buf;
320
    int res, fd;
321
    struct buff_data *buf_descriptor = pkt->priv;
322

    
323
    memset(&buf, 0, sizeof(struct v4l2_buffer));
324
    buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
325
    buf.memory = V4L2_MEMORY_MMAP;
326
    buf.index = buf_descriptor->index;
327
    fd = buf_descriptor->fd;
328
    av_free(buf_descriptor);
329

    
330
    res = ioctl (fd, VIDIOC_QBUF, &buf);
331
    if (res < 0) {
332
        av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
333
    }
334
    pkt->data = NULL;
335
    pkt->size = 0;
336
}
337

    
338
static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
339
{
340
    struct video_data *s = ctx->priv_data;
341
    struct v4l2_buffer buf;
342
    struct buff_data *buf_descriptor;
343
    int res;
344

    
345
    memset(&buf, 0, sizeof(struct v4l2_buffer));
346
    buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
347
    buf.memory = V4L2_MEMORY_MMAP;
348

    
349
    /* FIXME: Some special treatment might be needed in case of loss of signal... */
350
    while ((res = ioctl(s->fd, VIDIOC_DQBUF, &buf)) < 0 && (errno == EINTR));
351
    if (res < 0) {
352
        if (errno == EAGAIN) {
353
            pkt->size = 0;
354

    
355
            return AVERROR(EAGAIN);
356
        }
357
        av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_DQBUF): %s\n", strerror(errno));
358

    
359
        return -1;
360
    }
361
    assert (buf.index < s->buffers);
362
    if (buf.bytesused != s->frame_size) {
363
        av_log(ctx, AV_LOG_ERROR, "The v4l2 frame is %d bytes, but %d bytes are expected\n", buf.bytesused, s->frame_size);
364

    
365
        return -1;
366
    }
367

    
368
    /* Image is at s->buff_start[buf.index] */
369
    pkt->data= s->buf_start[buf.index];
370
    pkt->size = buf.bytesused;
371
    pkt->pts = buf.timestamp.tv_sec * INT64_C(1000000) + buf.timestamp.tv_usec;
372
    pkt->destruct = mmap_release_buffer;
373
    buf_descriptor = av_malloc(sizeof(struct buff_data));
374
    if (buf_descriptor == NULL) {
375
        /* Something went wrong... Since av_malloc() failed, we cannot even
376
         * allocate a buffer for memcopying into it
377
         */
378
        av_log(ctx, AV_LOG_ERROR, "Failed to allocate a buffer descriptor\n");
379
        res = ioctl (s->fd, VIDIOC_QBUF, &buf);
380

    
381
        return -1;
382
    }
383
    buf_descriptor->fd = s->fd;
384
    buf_descriptor->index = buf.index;
385
    pkt->priv = buf_descriptor;
386

    
387
    return s->buf_len[buf.index];
388
}
389

    
390
static int read_frame(AVFormatContext *ctx, AVPacket *pkt)
391
{
392
    return -1;
393
}
394

    
395
static int mmap_start(AVFormatContext *ctx)
396
{
397
    struct video_data *s = ctx->priv_data;
398
    enum v4l2_buf_type type;
399
    int i, res;
400

    
401
    for (i = 0; i < s->buffers; i++) {
402
        struct v4l2_buffer buf;
403

    
404
        memset(&buf, 0, sizeof(struct v4l2_buffer));
405
        buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
406
        buf.memory = V4L2_MEMORY_MMAP;
407
        buf.index  = i;
408

    
409
        res = ioctl (s->fd, VIDIOC_QBUF, &buf);
410
        if (res < 0) {
411
            av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n", strerror(errno));
412

    
413
            return -1;
414
        }
415
    }
416

    
417
    type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
418
    res = ioctl (s->fd, VIDIOC_STREAMON, &type);
419
    if (res < 0) {
420
        av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_STREAMON): %s\n", strerror(errno));
421

    
422
        return -1;
423
    }
424

    
425
    return 0;
426
}
427

    
428
static void mmap_close(struct video_data *s)
429
{
430
    enum v4l2_buf_type type;
431
    int i;
432

    
433
    type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
434
    /* We do not check for the result, because we could
435
     * not do anything about it anyway...
436
     */
437
    ioctl(s->fd, VIDIOC_STREAMOFF, &type);
438
    for (i = 0; i < s->buffers; i++) {
439
        munmap(s->buf_start[i], s->buf_len[i]);
440
    }
441
    av_free(s->buf_start);
442
    av_free(s->buf_len);
443
}
444

    
445
static int v4l2_set_parameters( AVFormatContext *s1, AVFormatParameters *ap )
446
{
447
    struct video_data *s = s1->priv_data;
448
    struct v4l2_input input;
449
    struct v4l2_standard standard;
450
    int i;
451

    
452
    if(ap->channel>=0) {
453
        /* set tv video input */
454
        memset (&input, 0, sizeof (input));
455
        input.index = ap->channel;
456
        if(ioctl (s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
457
            av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed:\n");
458
            return AVERROR(EIO);
459
        }
460

    
461
        av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set input_id: %d, input: %s\n",
462
               ap->channel, input.name);
463
        if(ioctl (s->fd, VIDIOC_S_INPUT, &input.index) < 0 ) {
464
            av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set input(%d) failed\n",
465
                   ap->channel);
466
            return AVERROR(EIO);
467
        }
468
    }
469

    
470
    if(ap->standard) {
471
        av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n",
472
               ap->standard );
473
        /* set tv standard */
474
        memset (&standard, 0, sizeof (standard));
475
        for(i=0;;i++) {
476
            standard.index = i;
477
            if (ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
478
                av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
479
                       ap->standard);
480
                return AVERROR(EIO);
481
            }
482

    
483
            if(!strcasecmp(standard.name, ap->standard)) {
484
                break;
485
            }
486
        }
487

    
488
        av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n",
489
               ap->standard, standard.id);
490
        if (ioctl(s->fd, VIDIOC_S_STD, &standard.id) < 0) {
491
            av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
492
                   ap->standard);
493
            return AVERROR(EIO);
494
        }
495
    }
496

    
497
    return 0;
498
}
499

    
500
static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
501
{
502
    struct video_data *s = s1->priv_data;
503
    AVStream *st;
504
    int width, height;
505
    int res, frame_rate, frame_rate_base;
506
    uint32_t desired_format, capabilities;
507

    
508
    if (ap->width <= 0 || ap->height <= 0) {
509
        av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", ap->width, ap->height);
510
        return -1;
511
    }
512
    if (ap->time_base.den <= 0) {
513
        av_log(s1, AV_LOG_ERROR, "Wrong time base (%d)\n", ap->time_base.den);
514
        return -1;
515
    }
516

    
517
    width = ap->width;
518
    height = ap->height;
519
    frame_rate = ap->time_base.den;
520
    frame_rate_base = ap->time_base.num;
521

    
522
    if((unsigned)width > 32767 || (unsigned)height > 32767) {
523
        av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", width, height);
524

    
525
        return -1;
526
    }
527

    
528
    st = av_new_stream(s1, 0);
529
    if (!st) {
530
        return AVERROR(ENOMEM);
531
    }
532
    av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
533

    
534
    s->width = width;
535
    s->height = height;
536
    s->frame_rate      = frame_rate;
537
    s->frame_rate_base = frame_rate_base;
538

    
539
    capabilities = 0;
540
    s->fd = device_open(s1, &capabilities);
541
    if (s->fd < 0) {
542
        return AVERROR(EIO);
543
    }
544
    av_log(s1, AV_LOG_INFO, "[%d]Capabilities: %x\n", s->fd, capabilities);
545

    
546
    desired_format = fmt_ff2v4l(ap->pix_fmt);
547
    if (desired_format == 0 || (device_init(s1, &width, &height, desired_format) < 0)) {
548
        int i, done;
549

    
550
        done = 0; i = 0;
551
        while (!done) {
552
            desired_format = fmt_conversion_table[i].v4l2_fmt;
553
            if (device_init(s1, &width, &height, desired_format) < 0) {
554
                desired_format = 0;
555
                i++;
556
            } else {
557
               done = 1;
558
            }
559
            if (i == sizeof(fmt_conversion_table) / sizeof(struct fmt_map)) {
560
               done = 1;
561
            }
562
        }
563
    }
564
    if (desired_format == 0) {
565
        av_log(s1, AV_LOG_ERROR, "Cannot find a proper format.\n");
566
        close(s->fd);
567

    
568
        return AVERROR(EIO);
569
    }
570
    s->frame_format = desired_format;
571

    
572
    if( v4l2_set_parameters( s1, ap ) < 0 )
573
        return AVERROR(EIO);
574

    
575
    st->codec->pix_fmt = fmt_v4l2ff(desired_format);
576
    s->frame_size = avpicture_get_size(st->codec->pix_fmt, width, height);
577
    if (capabilities & V4L2_CAP_STREAMING) {
578
        s->io_method = io_mmap;
579
        res = mmap_init(s1);
580
        if (res == 0) {
581
            res = mmap_start(s1);
582
        }
583
    } else {
584
        s->io_method = io_read;
585
        res = read_init(s1);
586
    }
587
    if (res < 0) {
588
        close(s->fd);
589

    
590
        return AVERROR(EIO);
591
    }
592
    s->top_field_first = first_field(s->fd);
593

    
594
    st->codec->codec_type = CODEC_TYPE_VIDEO;
595
    st->codec->codec_id = CODEC_ID_RAWVIDEO;
596
    st->codec->width = width;
597
    st->codec->height = height;
598
    st->codec->time_base.den = frame_rate;
599
    st->codec->time_base.num = frame_rate_base;
600
    st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
601

    
602
    return 0;
603
}
604

    
605
static int v4l2_read_packet(AVFormatContext *s1, AVPacket *pkt)
606
{
607
    struct video_data *s = s1->priv_data;
608
    int res;
609

    
610
    if (s->io_method == io_mmap) {
611
        av_init_packet(pkt);
612
        res = mmap_read_frame(s1, pkt);
613
    } else if (s->io_method == io_read) {
614
        if (av_new_packet(pkt, s->frame_size) < 0)
615
            return AVERROR(EIO);
616

    
617
        res = read_frame(s1, pkt);
618
    } else {
619
        return AVERROR(EIO);
620
    }
621
    if (res < 0) {
622
        return res;
623
    }
624

    
625
    if (s1->streams[0]->codec->coded_frame) {
626
        s1->streams[0]->codec->coded_frame->interlaced_frame = 1;
627
        s1->streams[0]->codec->coded_frame->top_field_first = s->top_field_first;
628
    }
629

    
630
    return s->frame_size;
631
}
632

    
633
static int v4l2_read_close(AVFormatContext *s1)
634
{
635
    struct video_data *s = s1->priv_data;
636

    
637
    if (s->io_method == io_mmap) {
638
        mmap_close(s);
639
    }
640

    
641
    close(s->fd);
642
    return 0;
643
}
644

    
645
AVInputFormat v4l2_demuxer = {
646
    "video4linux2",
647
    NULL_IF_CONFIG_SMALL("video grab"),
648
    sizeof(struct video_data),
649
    NULL,
650
    v4l2_read_header,
651
    v4l2_read_packet,
652
    v4l2_read_close,
653
    .flags = AVFMT_NOFILE,
654
};