[Ffmpeg-devel] video4linux2 input for testing

Erik Slagter erik
Fri Jan 27 13:14:47 CET 2006


On Fri, 2006-01-27 at 12:56 +0100, Luca Abeni wrote:

> ./ffmpeg -s 352x288 -pix_fmt <some pixel format> test.avi

I'd suggest testing with 720x576 or 720x480 (choose according to your
region). Of course this will give much better quality but also is a
better candidate for stress-testing.

-----------

> typedef struct video_data {
>     int fd;
>    int frame_format; /* V4L2_PIX_FMT_* */
> #define USE_READ        0
> #define USE_MMAP        1
> #define USE_POINTERS    2
>     int io_method;

Ouch... I'd suggest:

typedef enum
{
	use_read,
	use_mmap,
	use_pointers
} io_method_t;

typedef struct video_data {
	...
	io_method_t io_method;
	...
}

------------------------

>     int buffers;
>     void *buf_start[4];
>     int buf_len[4];
> } VideoData;

-------------------------

You never want to make the number of buffers static because this can
very largely, depending on the driver/card used and the resolution, the
available buffers can vary between 1 and ~256. Of course you will always
want to use the maximum number of buffers available.

 >   cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 >   res = ioctl(fd, VIDIOC_CROPCAP, &cropcap);
 >   if (res < 0) {
 >       /* Errors ignored. */
 >   } else {
 >       crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
 >       crop.c = cropcap.defrect; /* reset to default */
 >        
 >        res = ioctl(fd, VIDIOC_S_CROP, &crop);
 >        if (res < 0) {
 >           switch (errno) {
 >               case EINVAL:
 >                    /* Cropping not supported. */
 >                   break;
 >              default:
 >                  /* Errors ignored. */
 >                   break;
 >           }
 >       }
 >   }

FWIW, AFAIK only the saa7134 driver supports cropping (so you might not
be able to test it). It is a very nice feature though, because the
saa7134 hardware takes great care to do the cropping (and scaling!)
correctly, even for interlaced material. Not to mention it does it in
realtime ;-) It's great for removing unnecessary black borders.

>    req.count = 4;
>    req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
>    req.memory = V4L2_MEMORY_MMAP;

As mentioned before, you will always want to acquire as much buffers as
possible. You will need them.

 > *ts = buf.timestamp.tv_sec * int64_t_C(1000000) +
buf.timestamp.tv_usec;

Neat!
    
 > res = ioctl (s->fd, VIDIOC_QBUF, &buf);

Please note that at least the saa7134 (but probably the other drivers as
well) need some extra treatment for (temporary) loss of signal/sync. In
that case the driver tends to get stuck in a state where all QBUF and
DQBUF operations fail.

Great work!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2771 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060127/141a5595/attachment.bin>



More information about the ffmpeg-devel mailing list