diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2008-06-09 00:25:33 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2008-06-09 00:25:33 +0000 |
commit | 7ab088648b42d60cae752db8a0d1e5010e7d3462 (patch) | |
tree | e2f6a0a7b04eacfc5c33227275fb77810fa77579 | |
parent | 3438d82d4b3bd987304975961e2a42e82767107d (diff) | |
download | ffmpeg-7ab088648b42d60cae752db8a0d1e5010e7d3462.tar.gz |
add AVOption support in ffserver configuration file
Originally committed as revision 13719 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | ffserver.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/ffserver.c b/ffserver.c index cbd1512a84..5464176a45 100644 --- a/ffserver.c +++ b/ffserver.c @@ -32,7 +32,7 @@ #include "libavformat/os_support.h" #include "libavformat/rtp.h" #include "libavformat/rtsp.h" - +#include "libavcodec/opt.h" #include <stdarg.h> #include <unistd.h> #include <fcntl.h> @@ -3677,6 +3677,18 @@ static void load_module(const char *filename) } #endif +static int opt_default(const char *opt, const char *arg, + AVCodecContext *avctx, int type) +{ + const AVOption *o = NULL; + const AVOption *o2 = av_find_opt(avctx, opt, NULL, type, type); + if(o2) + o = av_set_string(avctx, opt, arg); + if(!o) + return -1; + return 0; +} + static int parse_ffconfig(const char *filename) { FILE *f; @@ -3881,6 +3893,7 @@ static int parse_ffconfig(const char *filename) fprintf(stderr, "%s:%d: Already in a tag\n", filename, line_num); } else { + const AVClass *class; stream = av_mallocz(sizeof(FFStream)); *last_stream = stream; last_stream = &stream->next; @@ -3890,8 +3903,15 @@ static int parse_ffconfig(const char *filename) if (*q) *q = '\0'; stream->fmt = guess_stream_format(NULL, stream->filename, NULL); + /* fetch avclass so AVOption works + * FIXME try to use avcodec_get_context_defaults2 + * without changing defaults too much */ + avcodec_get_context_defaults(&video_enc); + class = video_enc.av_class; memset(&audio_enc, 0, sizeof(AVCodecContext)); memset(&video_enc, 0, sizeof(AVCodecContext)); + audio_enc.av_class = class; + video_enc.av_class = class; audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; if (stream->fmt) { @@ -4088,6 +4108,24 @@ static int parse_ffconfig(const char *filename) video_enc.mb_decision = FF_MB_DECISION_BITS; //FIXME remove video_enc.flags |= CODEC_FLAG_4MV; } + } else if (!strcasecmp(cmd, "AVOptionVideo") || + !strcasecmp(cmd, "AVOptionAudio")) { + char arg2[1024]; + AVCodecContext *avctx; + int type; + get_arg(arg, sizeof(arg), &p); + get_arg(arg2, sizeof(arg2), &p); + if (!strcasecmp(cmd, "AVOptionVideo")) { + avctx = &video_enc; + type = AV_OPT_FLAG_VIDEO_PARAM; + } else { + avctx = &audio_enc; + type = AV_OPT_FLAG_AUDIO_PARAM; + } + if (opt_default(arg, arg2, avctx, type|AV_OPT_FLAG_ENCODING_PARAM)) { + fprintf(stderr, "AVOption error: %s %s\n", arg, arg2); + errors++; + } } else if (!strcasecmp(cmd, "VideoTag")) { get_arg(arg, sizeof(arg), &p); if ((strlen(arg) == 4) && stream) |