summaryrefslogtreecommitdiff
path: root/libavdevice
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2012-01-04 15:06:10 +0100
committerLuca Barbato <lu_zero@gentoo.org>2012-01-10 05:04:22 +0100
commitb8c310cb0a071d998b90e9b166ed29062524de8b (patch)
tree6b1b7a1d0f5fdc1f7466d7008715b0155fc50c0b /libavdevice
parentda2e774fd6841da7cede8c8ef30337449329727c (diff)
v4l2: support compressed formats
Let pass the codec name to -pixel_format and introduce -input_format.
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/v4l2.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 71e5b1159a..9c5da39e6a 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -708,11 +708,15 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
}
if (s->pixel_format) {
+ AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format);
+
+ if (codec)
+ s1->video_codec_id = codec->id;
pix_fmt = av_get_pix_fmt(s->pixel_format);
- if (pix_fmt == PIX_FMT_NONE) {
- av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n",
+ if (pix_fmt == PIX_FMT_NONE && !codec) {
+ av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format);
res = AVERROR(EINVAL);
@@ -818,7 +822,8 @@ static const AVOption options[] = {
{ "standard", "TV standard, used only by analog frame grabber", OFFSET(standard), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC },
{ "channel", "TV channel, used only by frame grabber", OFFSET(channel), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, DEC },
{ "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
- { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
+ { "pixel_format", "Preferred pixel format", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
+ { "input_format", "Preferred pixel format (for raw video) or codec name", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
{ "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
{ "list_formats", "List available formats and exit", OFFSET(list_format), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, DEC, "list_formats" },
{ "all", "Show all available formats", OFFSET(list_format), AV_OPT_TYPE_CONST, {.dbl = V4L_ALLFORMATS }, 0, INT_MAX, DEC, "list_formats" },