You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-09-16 08:36:51 +02:00
add AVOption support in ffserver configuration file
Originally committed as revision 13719 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
40
ffserver.c
40
ffserver.c
@@ -32,7 +32,7 @@
|
|||||||
#include "libavformat/os_support.h"
|
#include "libavformat/os_support.h"
|
||||||
#include "libavformat/rtp.h"
|
#include "libavformat/rtp.h"
|
||||||
#include "libavformat/rtsp.h"
|
#include "libavformat/rtsp.h"
|
||||||
|
#include "libavcodec/opt.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -3677,6 +3677,18 @@ static void load_module(const char *filename)
|
|||||||
}
|
}
|
||||||
#endif
|
#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)
|
static int parse_ffconfig(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
@@ -3881,6 +3893,7 @@ static int parse_ffconfig(const char *filename)
|
|||||||
fprintf(stderr, "%s:%d: Already in a tag\n",
|
fprintf(stderr, "%s:%d: Already in a tag\n",
|
||||||
filename, line_num);
|
filename, line_num);
|
||||||
} else {
|
} else {
|
||||||
|
const AVClass *class;
|
||||||
stream = av_mallocz(sizeof(FFStream));
|
stream = av_mallocz(sizeof(FFStream));
|
||||||
*last_stream = stream;
|
*last_stream = stream;
|
||||||
last_stream = &stream->next;
|
last_stream = &stream->next;
|
||||||
@@ -3890,8 +3903,15 @@ static int parse_ffconfig(const char *filename)
|
|||||||
if (*q)
|
if (*q)
|
||||||
*q = '\0';
|
*q = '\0';
|
||||||
stream->fmt = guess_stream_format(NULL, stream->filename, NULL);
|
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(&audio_enc, 0, sizeof(AVCodecContext));
|
||||||
memset(&video_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;
|
audio_id = CODEC_ID_NONE;
|
||||||
video_id = CODEC_ID_NONE;
|
video_id = CODEC_ID_NONE;
|
||||||
if (stream->fmt) {
|
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.mb_decision = FF_MB_DECISION_BITS; //FIXME remove
|
||||||
video_enc.flags |= CODEC_FLAG_4MV;
|
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")) {
|
} else if (!strcasecmp(cmd, "VideoTag")) {
|
||||||
get_arg(arg, sizeof(arg), &p);
|
get_arg(arg, sizeof(arg), &p);
|
||||||
if ((strlen(arg) == 4) && stream)
|
if ((strlen(arg) == 4) && stream)
|
||||||
|
Reference in New Issue
Block a user