From 1ff88e9f3b4d06770daf5fdb73e71257deee723c Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Mon, 18 May 2009 20:09:35 +0200 Subject: [PATCH] Allow to select video4linux version 1 formant from commandline. Implemented -i v4l and -i v4l2 options. Signed-off-by: Pavel Pisa --- input.c | 6 ++++-- input.h | 2 +- streamer.c | 12 ++++++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/input.c b/input.c index 14353b9..db09807 100644 --- a/input.c +++ b/input.c @@ -35,7 +35,7 @@ static void time_base_convert(AVPacket *pkt, AVStream *st) } } -AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps) +AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps, const char *impform) { AVFormatContext *s; AVInputFormat *fmt; @@ -49,7 +49,9 @@ AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps) param.pix_fmt = PIX_FMT_YUV420P; param.time_base.den = fps; param.time_base.num = 1; - fmt = av_find_input_format("video4linux2"); + if(impform == NULL) + impform = "video4linux2"; + fmt = av_find_input_format(impform); res = av_open_input_file(&s, fname, fmt, 0, ¶m); if (res < 0) { fprintf(stderr, "Error opening %s: %d\n", fname, res); diff --git a/input.h b/input.h index a992b34..ad82b6b 100644 --- a/input.h +++ b/input.h @@ -3,6 +3,6 @@ * * This is free software; see GPL.txt */ -AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps); +AVFormatContext *open_input_stream(const char *fname, int w, int h, int fps, const char *impform); void close_input_stream(AVFormatContext *s); AVPacket *read_input_packet(AVFormatContext *s); diff --git a/streamer.c b/streamer.c index 1a708cd..4185c16 100644 --- a/streamer.c +++ b/streamer.c @@ -22,6 +22,7 @@ static int dport = 20000; static int width = 352; static int height = 288; int fps = 25; +static const char *impform = "video4linux2"; static void sdp_print(AVFormatContext *s, const char *fname) { @@ -38,7 +39,7 @@ static int args_parse(int argc, char *argv[]) { int v; - while ((v = getopt(argc, argv, "w:h:r:d:m:")) >= 0) { + while ((v = getopt(argc, argv, "w:h:r:d:m:i:")) >= 0) { switch (v) { case 'w': width = atoi(optarg); @@ -55,6 +56,13 @@ static int args_parse(int argc, char *argv[]) case 'm': dst = optarg; break; + case 'i': + impform = optarg; + if(!strcmp(impform, "v4l")) + impform = "video4linux"; + else if(!strcmp(impform, "v4l2")) + impform = "video4linux2"; + break; default: /* ’?’ */ fprintf(stderr, "%s: illegal option %c\n", argv[0], v); exit(-1); @@ -75,7 +83,7 @@ int main(int argc, char *argv[]) args_parse(argc, argv); - s = open_input_stream(vdev, width, height, fps); + s = open_input_stream(vdev, width, height, fps, impform); if (s == NULL) { fprintf(stderr, "Cannot open input file %s\n", vdev); -- 2.39.2