[FFmpeg-devel] [PATCH] V4L2 compliance: Make sure VIDIOC_S_INPUT is called before querying/setting any input properties

Rupert Eibauer Rupert.Eibauer at ces.ch
Wed Jan 11 20:01:25 CET 2012


Hello,

This solves a problem with a V4L device which supports different inputs.
The problem is that the different inputs have different resolutions, and 
the device cannot do image scaling.
This is what happened:
- ffmpeg calls VIDIOC_S_FMT with the resolution we specified on the 
command line.
- The driver responds with a resolution which is correct for the default 
input.
- ffmpeg calls VIDIOC_S_INPUT, and the driver switches to the resolution 
supported by that input.
- Now we have a problem: ffmpegs idea about the image resolution is wrong. 


The patch below fixes that problem. Please apply it.
It is for 0.8.9, because this is the version I am currently using. 0.9.1 
and git do not compile because of some asm errors.


--- ffmpeg-0.8.9.orig/libavdevice/v4l2.c        2011-12-25 
22:18:30.000000000 +0100 
+++ ffmpeg-0.8.9/libavdevice/v4l2.c     2012-01-11 18:43:47.000000000 
+0100
@@ -621,6 +621,9 @@
         av_log(s1, AV_LOG_VERBOSE, "Setting frame size to %dx%d\n", 
s->width, s->height);
     }

+    if ((res = v4l2_set_parameters(s1, ap) < 0))
+        goto out;
+
     desired_format = device_try_init(s1, pix_fmt, &s->width, &s->height, 
&codec_id);
     if (desired_format == 0) {
         av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for "
@@ -634,9 +637,6 @@
         goto out;
     s->frame_format = desired_format;

-    if ((res = v4l2_set_parameters(s1, ap) < 0))
-        goto out;
-
     st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
     s->frame_size = avpicture_get_size(st->codec->pix_fmt, s->width, 
s->height);
     if (capabilities & V4L2_CAP_STREAMING) {


Best regards,
Rupert Eibauer


More information about the ffmpeg-devel mailing list