[FFmpeg-cvslog] lavd/v4l2: add list_standards option

Giorgio Vazzana git at videolan.org
Thu Jan 31 12:40:13 CET 2013


ffmpeg | branch: master | Giorgio Vazzana <mywing81 at gmail.com> | Wed Jan 30 13:17:02 2013 +0100| [ff23b76899b289855bb5a7e074673f3e07e5a7cf] | committer: Stefano Sabatini

lavd/v4l2: add list_standards option

Since the user is expected to choose the standard by name (with -standard
option), add the possibility to list all the supported standards.

Signed-off-by: Stefano Sabatini <stefasab at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff23b76899b289855bb5a7e074673f3e07e5a7cf
---

 doc/indevs.texi       |    2 ++
 libavdevice/v4l2.c    |   33 +++++++++++++++++++++++++++++++++
 libavdevice/version.h |    2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 621e1de..82d500d 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -596,6 +596,8 @@ the device.
 Video4Linux2 devices usually support a limited set of
 @var{width}x at var{height} sizes and framerates. You can check which are
 supported using @command{-list_formats all} for Video4Linux2 devices.
+Some devices, like TV cards, support one or more standards. It is possible
+to list all the supported standards using @command{-list_standards all}.
 
 Some usage examples of the video4linux2 devices with ffmpeg and ffplay:
 
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 5f01027..76b6d64 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -116,6 +116,7 @@ struct video_data {
     int channel;
     char *pixel_format; /**< Set by a private option. */
     int list_format;    /**< Set by a private option. */
+    int list_standard;  /**< Set by a private option. */
     char *framerate;    /**< Set by a private option. */
 };
 
@@ -381,6 +382,30 @@ static void list_formats(AVFormatContext *ctx, int fd, int type)
     }
 }
 
+static void list_standards(AVFormatContext *ctx)
+{
+    int ret;
+    struct video_data *s = ctx->priv_data;
+    struct v4l2_standard standard;
+
+    if (s->std_id == 0)
+        return;
+
+    for (standard.index = 0; ; standard.index++) {
+        ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard);
+        if (ret < 0) {
+            if (errno == EINVAL)
+                break;
+            else {
+                av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", strerror(errno));
+                return;
+            }
+        }
+        av_log(ctx, AV_LOG_INFO, "%2d, %16llx, %s\n",
+               standard.index, standard.id, standard.name);
+    }
+}
+
 static int mmap_init(AVFormatContext *ctx)
 {
     int i, res;
@@ -824,6 +849,11 @@ static int v4l2_read_header(AVFormatContext *s1)
         return AVERROR_EXIT;
     }
 
+    if (s->list_standard) {
+        list_standards(s1);
+        return AVERROR_EXIT;
+    }
+
     avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
 
     if (s->pixel_format) {
@@ -952,6 +982,9 @@ static const AVOption options[] = {
     { "raw",          "show only non-compressed formats",                         OFFSET(list_format),  AV_OPT_TYPE_CONST,  {.i64 = V4L_RAWFORMATS  },    0, INT_MAX, DEC, "list_formats" },
     { "compressed",   "show only compressed formats",                             OFFSET(list_format),  AV_OPT_TYPE_CONST,  {.i64 = V4L_COMPFORMATS },    0, INT_MAX, DEC, "list_formats" },
 
+    { "list_standards", "list supported standards and exit",                      OFFSET(list_standard), AV_OPT_TYPE_INT,   {.i64 = 0 },  0, 1, DEC, "list_standards" },
+    { "all",            "show all supported standards",                           OFFSET(list_standard), AV_OPT_TYPE_CONST, {.i64 = 1 },  0, 0, DEC, "list_standards" },
+
     { "timestamps",   "set type of timestamps for grabbed frames",                OFFSET(ts_mode),      AV_OPT_TYPE_INT,    {.i64 = 0 }, 0, 2, DEC, "timestamps" },
     { "ts",           "set type of timestamps for grabbed frames",                OFFSET(ts_mode),      AV_OPT_TYPE_INT,    {.i64 = 0 }, 0, 2, DEC, "timestamps" },
     { "default",      "use timestamps from the kernel",                           OFFSET(ts_mode),      AV_OPT_TYPE_CONST,  {.i64 = V4L_TS_DEFAULT  }, 0, 2, DEC, "timestamps" },
diff --git a/libavdevice/version.h b/libavdevice/version.h
index 5eed4f5..9e0c0ae 100644
--- a/libavdevice/version.h
+++ b/libavdevice/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVDEVICE_VERSION_MAJOR  54
 #define LIBAVDEVICE_VERSION_MINOR   3
-#define LIBAVDEVICE_VERSION_MICRO 102
+#define LIBAVDEVICE_VERSION_MICRO 103
 
 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
                                                LIBAVDEVICE_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list