[FFmpeg-devel] [PATCH] lavd/v4l2: add list_standards option
Giorgio Vazzana
mywing81 at gmail.com
Wed Jan 30 13:40:08 CET 2013
2013/1/30 Stefano Sabatini <stefasab at gmail.com>:
> On date Tuesday 2013-01-29 13:16:33 +0100, Giorgio Vazzana encoded:
>> Useful / not useful?
>
> Possibly useful.
>
> BTW this would be also useful at the programmatic level, if you can
> get your head around the recently added av_opt_query_* API.
Ok, I have never used it, I will try to read up on that.
>> From be3fa89c581a959b0b01321b1b737add2bc028ac Mon Sep 17 00:00:00 2001
>> From: Giorgio Vazzana <mywing81 at gmail.com>
>> Date: Tue, 29 Jan 2013 13:11:01 +0100
>> Subject: [PATCH] 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.
>> ---
>> libavdevice/v4l2.c | 35 +++++++++++++++++++++++++++++++++++
>> 1 files changed, 35 insertions(+), 0 deletions(-)
>
> Missing documentation update.
Added two lines mentioning the new option.
>>
>> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
>> index 879201f..95bb477 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,32 @@ 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) {
>> + av_log(ctx, AV_LOG_WARNING, "This device does not support any standard\n");
>> + return;
>> + }
>
> Possibly more script-friendly, don't output nothing in case of no
> supported standards.
Changed.
>> +
>> + 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, "Std: %2d, 0x%016llx, %s\n",
>> + standard.index, standard.id, standard.name);
>
> "Std:" may be replaced by "Standard" or dropped altogether since the
> user knows what she asked for, maybe you could remove the many leading
> "0" in the ID.
Dropped "Std:" and the leading zeros. I don't have a preference on the
format used, as long as the user can list all the standards. Feel free
to change it if you want.
> I have no special objections to the current form but some more thought
> about the most preferrable format can't hurt. OTOH the output is meant
> for the human reader thus we can change it later without infliciting
> too much pain to users.
Ok.
> BTW what's the type of "standard.id"?
standard.id field is of type "v4l2_std_id", which is:
typedef __u64 v4l2_std_id;
please see: http://linuxtv.org/downloads/v4l-dvb-apis/vidioc-enumstd.html#v4l2-std-id
> LGTM otherwise.
Ok, new patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavd-v4l2-add-list_standards-option.patch
Type: application/octet-stream
Size: 3949 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130130/859d9f5b/attachment.obj>
More information about the ffmpeg-devel
mailing list