[FFmpeg-devel] libavformat and video4linux2 acquire problems

Limin Wang lance.lmwang
Wed May 9 16:00:13 CEST 2007


Hi luca,

> [...]
> >> What does a NULL tvstd mean? Does it leave the tv standard as it is, 
> >> without trying to set it? If yes, I think we need this patch.
> > 
> > Yes, it'll leave the tv standard as system is if it's NULL. I'll submit
> > it tonight for review.
> Good, thanks.
> 
> [...]
> > With int value, you had to try with 0, 1, 2, 3 even you know it's S-video
> > input. If you're preferable to use int, I'll not submit this change. So 
> > how about to use -1 to leave default system config as tvstd use NULL?
> This (the "-1 == do not try to set the input" thing) would be very 
> useful (assuming it does not break other things...).
> If you provide a patch, and it does not break dv capturing or similar 
> things, I'll be very happy to apply it.

Please review the attached patch, I have check dv1394, it'll not break if
standard is NULL and input is -1 case.


Thanks,
Limin


-------------- next part --------------
Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 8950)
+++ ffmpeg.c	(working copy)
@@ -181,8 +181,8 @@
 
 static int rate_emu = 0;
 
-static int  video_channel = 0;
-static char *video_standard = "ntsc";
+static int  video_channel = -1;
+static char *video_standard;
 
 static int audio_volume = 256;
 
@@ -3833,7 +3833,8 @@
     av_free(vstats_filename);
 
     av_free(opt_names);
-
+    av_free(video_standard);
+    
 #ifdef CONFIG_POWERPC_PERF
     extern void powerpc_display_perf_report(void);
     powerpc_display_perf_report();
Index: libavformat/v4l2.c
===================================================================
--- libavformat/v4l2.c	(revision 8950)
+++ libavformat/v4l2.c	(working copy)
@@ -429,47 +429,51 @@
     struct v4l2_standard standard;
     int i;
 
-    /* set tv video input */
-    memset (&input, 0, sizeof (input));
-    input.index = ap->channel;
-    if(ioctl (s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
-        av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed:\n");
-        return AVERROR_IO;
-    }
+    if(ap->channel>=0) {
+        /* set tv video input */
+        memset (&input, 0, sizeof (input));
+        input.index = ap->channel;
+        if(ioctl (s->fd, VIDIOC_ENUMINPUT, &input) < 0) {
+            av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl enum input failed:\n");
+            return AVERROR_IO;
+        }
 
-    av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set input_id: %d, input: %s\n",
-           ap->channel, input.name);
-    if(ioctl (s->fd, VIDIOC_S_INPUT, &input.index) < 0 ) {
-        av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set input(%d) failed\n",
-            ap->channel);
-        return AVERROR_IO;
+        av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set input_id: %d, input: %s\n",
+               ap->channel, input.name);
+        if(ioctl (s->fd, VIDIOC_S_INPUT, &input.index) < 0 ) {
+            av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set input(%d) failed\n",
+                   ap->channel);
+            return AVERROR_IO;
+        }
     }
 
-    av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n",
-           ap->standard );
-    /* set tv standard */
-    memset (&standard, 0, sizeof (standard));
-    for(i=0;;i++) {
-        standard.index = i;
-        if (ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
+    if(ap->standard) {
+        av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s\n",
+               ap->standard );
+        /* set tv standard */
+        memset (&standard, 0, sizeof (standard));
+        for(i=0;;i++) {
+            standard.index = i;
+            if (ioctl(s->fd, VIDIOC_ENUMSTD, &standard) < 0) {
+                av_log(s1, AV_LOG_ERROR, "The V4L2 driver ioctl set standard(%s) failed\n",
+                       ap->standard);
+                return AVERROR_IO;
+            }
+
+            if(!strcasecmp(standard.name, ap->standard)) {
+                break;
+            }
+        }
+
+        av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n",
+               ap->standard, 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);
             return AVERROR_IO;
         }
-
-        if(!strcasecmp(standard.name, ap->standard)) {
-            break;
-        }
     }
 
-    av_log(s1, AV_LOG_DEBUG, "The V4L2 driver set standard: %s, id: %"PRIu64"\n",
-           ap->standard, 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);
-        return AVERROR_IO;
-    }
-
     return 0;
 }
 



More information about the ffmpeg-devel mailing list