mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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@gmail.com>
This commit is contained in:
parent
dcfbe1e0b6
commit
ff23b76899
@ -596,6 +596,8 @@ the device.
|
||||
Video4Linux2 devices usually support a limited set of
|
||||
@var{width}x@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:
|
||||
|
||||
|
@ -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" },
|
||||
|
@ -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, \
|
||||
|
Loading…
Reference in New Issue
Block a user