...
|
...
|
@@ -470,6 +470,9 @@ static int ffserver_save_avoption(const char *opt, const char *arg, int type, FF
|
470
|
470
|
}
|
471
|
471
|
|
472
|
472
|
o = av_opt_find(ctx, option, NULL, type | AV_OPT_FLAG_ENCODING_PARAM, AV_OPT_SEARCH_CHILDREN);
|
|
473
|
+ if (!o && (!strcmp(option, "time_base") || !strcmp(option, "pixel_format") ||
|
|
474
|
+ !strcmp(option, "video_size") || !strcmp(option, "codec_tag")))
|
|
475
|
+ o = av_opt_find(ctx, option, NULL, 0, 0);
|
473
|
476
|
if (!o) {
|
474
|
477
|
report_config_error(config->filename, config->line_num, AV_LOG_ERROR,
|
475
|
478
|
&config->errors, "Option not found: %s\n", opt);
|
...
|
...
|
@@ -497,6 +500,14 @@ static int ffserver_save_avoption(const char *opt, const char *arg, int type, FF
|
497
|
497
|
return 0;
|
498
|
498
|
}
|
499
|
499
|
|
|
500
|
+static int ffserver_save_avoption_int(const char *opt, int64_t arg,
|
|
501
|
+ int type, FFServerConfig *config)
|
|
502
|
+{
|
|
503
|
+ char buf[22];
|
|
504
|
+ snprintf(buf, sizeof(buf), "%"PRId64, arg);
|
|
505
|
+ return ffserver_save_avoption(opt, buf, type, config);
|
|
506
|
+}
|
|
507
|
+
|
500
|
508
|
#define ERROR(...) report_config_error(config->filename, config->line_num, AV_LOG_ERROR, &config->errors, __VA_ARGS__)
|
501
|
509
|
#define WARNING(...) report_config_error(config->filename, config->line_num, AV_LOG_WARNING, &config->warnings, __VA_ARGS__)
|
502
|
510
|
|
...
|
...
|
@@ -673,105 +684,10 @@ static int ffserver_parse_config_feed(FFServerConfig *config, const char *cmd, c
|
673
|
673
|
return 0;
|
674
|
674
|
}
|
675
|
675
|
|
676
|
|
-static void ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary *conf, AVDictionary **opts)
|
|
676
|
+static void ffserver_apply_stream_config(AVCodecContext *enc, AVDictionary **opts)
|
677
|
677
|
{
|
678
|
|
- AVDictionaryEntry *e;
|
679
|
|
-
|
680
|
|
- /* Return values from ffserver_set_*_param are ignored.
|
681
|
|
- Values are initially parsed and checked before inserting to
|
682
|
|
- AVDictionary. */
|
683
|
|
-
|
684
|
|
- //video params
|
685
|
|
- if ((e = av_dict_get(conf, "VideoBitRateRangeMin", NULL, 0)))
|
686
|
|
- ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN,
|
687
|
|
- INT_MAX, NULL, 0, NULL);
|
688
|
|
- if ((e = av_dict_get(conf, "VideoBitRateRangeMax", NULL, 0)))
|
689
|
|
- ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN,
|
690
|
|
- INT_MAX, NULL, 0, NULL);
|
691
|
|
- if ((e = av_dict_get(conf, "Debug", NULL, 0)))
|
692
|
|
- ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX,
|
693
|
|
- NULL, 0, NULL);
|
694
|
|
- if ((e = av_dict_get(conf, "Strict", NULL, 0)))
|
695
|
|
- ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0,
|
696
|
|
- INT_MIN, INT_MAX, NULL, 0, NULL);
|
697
|
|
- if ((e = av_dict_get(conf, "VideoBufferSize", NULL, 0)))
|
698
|
|
- ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024,
|
699
|
|
- INT_MIN, INT_MAX, NULL, 0, NULL);
|
700
|
|
- if ((e = av_dict_get(conf, "VideoBitRateTolerance", NULL, 0)))
|
701
|
|
- ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000,
|
702
|
|
- INT_MIN, INT_MAX, NULL, 0, NULL);
|
703
|
|
- if ((e = av_dict_get(conf, "VideoBitRate", NULL, 0)))
|
704
|
|
- ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN,
|
705
|
|
- INT_MAX, NULL, 0, NULL);
|
706
|
|
- if ((e = av_dict_get(conf, "VideoSizeWidth", NULL, 0)))
|
707
|
|
- ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX,
|
708
|
|
- NULL, 0, NULL);
|
709
|
|
- if ((e = av_dict_get(conf, "VideoSizeHeight", NULL, 0)))
|
710
|
|
- ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX,
|
711
|
|
- NULL, 0, NULL);
|
712
|
|
- if ((e = av_dict_get(conf, "PixelFormat", NULL, 0))) {
|
713
|
|
- int val;
|
714
|
|
- ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0,
|
715
|
|
- NULL);
|
716
|
|
- enc->pix_fmt = val;
|
717
|
|
- }
|
718
|
|
- if ((e = av_dict_get(conf, "VideoGopSize", NULL, 0)))
|
719
|
|
- ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX,
|
720
|
|
- NULL, 0, NULL);
|
721
|
|
- if ((e = av_dict_get(conf, "VideoFrameRateNum", NULL, 0)))
|
722
|
|
- ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN,
|
723
|
|
- INT_MAX, NULL, 0, NULL);
|
724
|
|
- if ((e = av_dict_get(conf, "VideoFrameRateDen", NULL, 0)))
|
725
|
|
- ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN,
|
726
|
|
- INT_MAX, NULL, 0, NULL);
|
727
|
|
- if ((e = av_dict_get(conf, "VideoQDiff", NULL, 0)))
|
728
|
|
- ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX,
|
729
|
|
- NULL, 0, NULL);
|
730
|
|
- if ((e = av_dict_get(conf, "VideoQMax", NULL, 0)))
|
731
|
|
- ffserver_set_int_param(&enc->qmax, e->value, 0, INT_MIN, INT_MAX, NULL,
|
732
|
|
- 0, NULL);
|
733
|
|
- if ((e = av_dict_get(conf, "VideoQMin", NULL, 0)))
|
734
|
|
- ffserver_set_int_param(&enc->qmin, e->value, 0, INT_MIN, INT_MAX, NULL,
|
735
|
|
- 0, NULL);
|
736
|
|
- if ((e = av_dict_get(conf, "LumiMask", NULL, 0)))
|
737
|
|
- ffserver_set_float_param(&enc->lumi_masking, e->value, 0, -FLT_MAX,
|
738
|
|
- FLT_MAX, NULL, 0, NULL);
|
739
|
|
- if ((e = av_dict_get(conf, "DarkMask", NULL, 0)))
|
740
|
|
- ffserver_set_float_param(&enc->dark_masking, e->value, 0, -FLT_MAX,
|
741
|
|
- FLT_MAX, NULL, 0, NULL);
|
742
|
|
- if (av_dict_get(conf, "BitExact", NULL, 0))
|
743
|
|
- enc->flags |= CODEC_FLAG_BITEXACT;
|
744
|
|
- if (av_dict_get(conf, "DctFastint", NULL, 0))
|
745
|
|
- enc->dct_algo = FF_DCT_FASTINT;
|
746
|
|
- if (av_dict_get(conf, "IdctSimple", NULL, 0))
|
747
|
|
- enc->idct_algo = FF_IDCT_SIMPLE;
|
748
|
|
- if (av_dict_get(conf, "VideoHighQuality", NULL, 0))
|
749
|
|
- enc->mb_decision = FF_MB_DECISION_BITS;
|
750
|
|
- if ((e = av_dict_get(conf, "VideoTag", NULL, 0)))
|
751
|
|
- enc->codec_tag = MKTAG(e->value[0], e->value[1], e->value[2], e->value[3]);
|
752
|
|
- if ((e = av_dict_get(conf, "Qscale", NULL, 0))) {
|
753
|
|
- enc->flags |= CODEC_FLAG_QSCALE;
|
754
|
|
- ffserver_set_int_param(&enc->global_quality, e->value, FF_QP2LAMBDA,
|
755
|
|
- INT_MIN, INT_MAX, NULL, 0, NULL);
|
756
|
|
- }
|
757
|
|
- if (av_dict_get(conf, "Video4MotionVector", NULL, 0)) {
|
758
|
|
- enc->mb_decision = FF_MB_DECISION_BITS; //FIXME remove
|
759
|
|
- enc->flags |= CODEC_FLAG_4MV;
|
760
|
|
- }
|
761
|
|
- //audio params
|
762
|
|
- if ((e = av_dict_get(conf, "AudioChannels", NULL, 0)))
|
763
|
|
- ffserver_set_int_param(&enc->channels, e->value, 0, INT_MIN, INT_MAX,
|
764
|
|
- NULL, 0, NULL);
|
765
|
|
- if ((e = av_dict_get(conf, "AudioSampleRate", NULL, 0)))
|
766
|
|
- ffserver_set_int_param(&enc->sample_rate, e->value, 0, INT_MIN,
|
767
|
|
- INT_MAX, NULL, 0, NULL);
|
768
|
|
- if ((e = av_dict_get(conf, "AudioBitRate", NULL, 0)))
|
769
|
|
- ffserver_set_int_param(&enc->bit_rate, e->value, 0, INT_MIN, INT_MAX,
|
770
|
|
- NULL, 0, NULL);
|
771
|
|
-
|
772
|
678
|
av_opt_set_dict2(enc->priv_data, opts, AV_OPT_SEARCH_CHILDREN);
|
773
|
679
|
av_opt_set_dict2(enc, opts, AV_OPT_SEARCH_CHILDREN);
|
774
|
|
-
|
775
|
680
|
if (av_dict_count(*opts))
|
776
|
681
|
av_log(NULL, AV_LOG_ERROR, "Something went wrong, %d options not set!!!\n", av_dict_count(*opts));
|
777
|
682
|
}
|
...
|
...
|
@@ -903,61 +819,62 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
|
903
|
903
|
} else if (!av_strcasecmp(cmd, "AudioBitRate")) {
|
904
|
904
|
float f;
|
905
|
905
|
ffserver_get_arg(arg, sizeof(arg), p);
|
906
|
|
- ffserver_set_float_param(&f, arg, 1000, 0, FLT_MAX, config,
|
|
906
|
+ ffserver_set_float_param(&f, arg, 1000, -FLT_MAX, FLT_MAX, config,
|
907
|
907
|
"Invalid %s: %s\n", cmd, arg);
|
908
|
|
- if (av_dict_set_int(&config->audio_conf, cmd, lrintf(f), 0) < 0)
|
|
908
|
+ if (ffserver_save_avoption_int("ab", (int64_t)lrintf(f), AV_OPT_FLAG_AUDIO_PARAM, config) < 0)
|
909
|
909
|
goto nomem;
|
910
|
910
|
} else if (!av_strcasecmp(cmd, "AudioChannels")) {
|
911
|
911
|
ffserver_get_arg(arg, sizeof(arg), p);
|
912
|
|
- ffserver_set_int_param(NULL, arg, 0, 1, 8, config,
|
913
|
|
- "Invalid %s: %s, valid range is 1-8.", cmd, arg);
|
914
|
|
- if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0)
|
|
912
|
+ if (ffserver_save_avoption("ac", arg, AV_OPT_FLAG_AUDIO_PARAM, config) < 0)
|
915
|
913
|
goto nomem;
|
916
|
914
|
} else if (!av_strcasecmp(cmd, "AudioSampleRate")) {
|
917
|
915
|
ffserver_get_arg(arg, sizeof(arg), p);
|
918
|
|
- ffserver_set_int_param(NULL, arg, 0, 0, INT_MAX, config,
|
919
|
|
- "Invalid %s: %s", cmd, arg);
|
920
|
|
- if (av_dict_set(&config->audio_conf, cmd, arg, 0) < 0)
|
|
916
|
+ if (ffserver_save_avoption("ar", arg, AV_OPT_FLAG_AUDIO_PARAM, config) < 0)
|
921
|
917
|
goto nomem;
|
922
|
918
|
} else if (!av_strcasecmp(cmd, "VideoBitRateRange")) {
|
923
|
919
|
int minrate, maxrate;
|
|
920
|
+ char *dash;
|
924
|
921
|
ffserver_get_arg(arg, sizeof(arg), p);
|
925
|
|
- if (sscanf(arg, "%d-%d", &minrate, &maxrate) == 2) {
|
926
|
|
- if (av_dict_set_int(&config->video_conf, "VideoBitRateRangeMin", minrate, 0) < 0 ||
|
927
|
|
- av_dict_set_int(&config->video_conf, "VideoBitRateRangeMax", maxrate, 0) < 0)
|
|
922
|
+ dash = strchr(arg, '-');
|
|
923
|
+ if (dash) {
|
|
924
|
+ *dash = '\0';
|
|
925
|
+ dash++;
|
|
926
|
+ if (ffserver_set_int_param(&minrate, arg, 1000, 0, INT_MAX, config, "Invalid %s: %s", cmd, arg) >= 0 &&
|
|
927
|
+ ffserver_set_int_param(&maxrate, dash, 1000, 0, INT_MAX, config, "Invalid %s: %s", cmd, arg) >= 0) {
|
|
928
|
+ if (ffserver_save_avoption_int("minrate", minrate, AV_OPT_FLAG_VIDEO_PARAM, config) < 0 ||
|
|
929
|
+ ffserver_save_avoption_int("maxrate", maxrate, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
928
|
930
|
goto nomem;
|
|
931
|
+ }
|
929
|
932
|
} else
|
930
|
933
|
ERROR("Incorrect format for VideoBitRateRange -- should be "
|
931
|
934
|
"<min>-<max>: %s\n", arg);
|
932
|
935
|
} else if (!av_strcasecmp(cmd, "Debug")) {
|
933
|
936
|
ffserver_get_arg(arg, sizeof(arg), p);
|
934
|
|
- ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config,
|
935
|
|
- "Invalid %s: %s", cmd, arg);
|
936
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
937
|
+ if (ffserver_save_avoption("debug", arg, AV_OPT_FLAG_AUDIO_PARAM, config) < 0 ||
|
|
938
|
+ ffserver_save_avoption("debug", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
937
|
939
|
goto nomem;
|
938
|
940
|
} else if (!av_strcasecmp(cmd, "Strict")) {
|
939
|
941
|
ffserver_get_arg(arg, sizeof(arg), p);
|
940
|
|
- ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config,
|
941
|
|
- "Invalid %s: %s", cmd, arg);
|
942
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
942
|
+ if (ffserver_save_avoption("strict", arg, AV_OPT_FLAG_AUDIO_PARAM, config) < 0 ||
|
|
943
|
+ ffserver_save_avoption("strict", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
943
|
944
|
goto nomem;
|
944
|
945
|
} else if (!av_strcasecmp(cmd, "VideoBufferSize")) {
|
945
|
946
|
ffserver_get_arg(arg, sizeof(arg), p);
|
946
|
|
- ffserver_set_int_param(NULL, arg, 8*1024, 0, INT_MAX, config,
|
|
947
|
+ ffserver_set_int_param(&val, arg, 8*1024, 0, INT_MAX, config,
|
947
|
948
|
"Invalid %s: %s", cmd, arg);
|
948
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
949
|
+ if (ffserver_save_avoption_int("bufsize", val, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
949
|
950
|
goto nomem;
|
950
|
951
|
} else if (!av_strcasecmp(cmd, "VideoBitRateTolerance")) {
|
951
|
952
|
ffserver_get_arg(arg, sizeof(arg), p);
|
952
|
|
- ffserver_set_int_param(NULL, arg, 1000, INT_MIN, INT_MAX, config,
|
|
953
|
+ ffserver_set_int_param(&val, arg, 1000, INT_MIN, INT_MAX, config,
|
953
|
954
|
"Invalid %s: %s", cmd, arg);
|
954
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
955
|
+ if (ffserver_save_avoption_int("bt", val, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
955
|
956
|
goto nomem;
|
956
|
957
|
} else if (!av_strcasecmp(cmd, "VideoBitRate")) {
|
957
|
958
|
ffserver_get_arg(arg, sizeof(arg), p);
|
958
|
|
- ffserver_set_int_param(NULL, arg, 1000, 0, INT_MAX, config,
|
|
959
|
+ ffserver_set_int_param(&val, arg, 1000, INT_MIN, INT_MAX, config,
|
959
|
960
|
"Invalid %s: %s", cmd, arg);
|
960
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
961
|
+ if (ffserver_save_avoption_int("b", val, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
961
|
962
|
goto nomem;
|
962
|
963
|
} else if (!av_strcasecmp(cmd, "VideoSize")) {
|
963
|
964
|
int ret, w, h;
|
...
|
...
|
@@ -965,43 +882,38 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
|
965
|
965
|
ret = av_parse_video_size(&w, &h, arg);
|
966
|
966
|
if (ret < 0)
|
967
|
967
|
ERROR("Invalid video size '%s'\n", arg);
|
968
|
|
- else if ((w % 2) || (h % 2))
|
969
|
|
- WARNING("Image size is not a multiple of 2\n");
|
970
|
|
- if (av_dict_set_int(&config->video_conf, "VideoSizeWidth", w, 0) < 0 ||
|
971
|
|
- av_dict_set_int(&config->video_conf, "VideoSizeHeight", h, 0) < 0)
|
972
|
|
- goto nomem;
|
973
|
|
- } else if (!av_strcasecmp(cmd, "VideoFrameRate")) {
|
974
|
|
- AVRational frame_rate;
|
975
|
|
- ffserver_get_arg(arg, sizeof(arg), p);
|
976
|
|
- if (av_parse_video_rate(&frame_rate, arg) < 0) {
|
977
|
|
- ERROR("Incorrect frame rate: %s\n", arg);
|
978
|
|
- } else {
|
979
|
|
- if (av_dict_set_int(&config->video_conf, "VideoFrameRateNum", frame_rate.num, 0) < 0 ||
|
980
|
|
- av_dict_set_int(&config->video_conf, "VideoFrameRateDen", frame_rate.den, 0) < 0)
|
|
968
|
+ else {
|
|
969
|
+ if (w % 2 || h % 2)
|
|
970
|
+ WARNING("Image size is not a multiple of 2\n");
|
|
971
|
+ if (ffserver_save_avoption("video_size", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
981
|
972
|
goto nomem;
|
982
|
973
|
}
|
|
974
|
+ } else if (!av_strcasecmp(cmd, "VideoFrameRate")) {
|
|
975
|
+ ffserver_get_arg(&arg[2], sizeof(arg) - 2, p);
|
|
976
|
+ arg[0] = '1'; arg[1] = '/';
|
|
977
|
+ if (ffserver_save_avoption("time_base", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
|
978
|
+ goto nomem;
|
983
|
979
|
} else if (!av_strcasecmp(cmd, "PixelFormat")) {
|
984
|
980
|
enum AVPixelFormat pix_fmt;
|
985
|
981
|
ffserver_get_arg(arg, sizeof(arg), p);
|
986
|
982
|
pix_fmt = av_get_pix_fmt(arg);
|
987
|
983
|
if (pix_fmt == AV_PIX_FMT_NONE)
|
988
|
984
|
ERROR("Unknown pixel format: %s\n", arg);
|
989
|
|
- if (av_dict_set_int(&config->video_conf, cmd, pix_fmt, 0) < 0)
|
|
985
|
+ else if (ffserver_save_avoption("pixel_format", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
990
|
986
|
goto nomem;
|
991
|
987
|
} else if (!av_strcasecmp(cmd, "VideoGopSize")) {
|
992
|
988
|
ffserver_get_arg(arg, sizeof(arg), p);
|
993
|
|
- ffserver_set_int_param(NULL, arg, 0, INT_MIN, INT_MAX, config,
|
994
|
|
- "Invalid %s: %s", cmd, arg);
|
995
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
989
|
+ if (ffserver_save_avoption("g", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
996
|
990
|
goto nomem;
|
997
|
991
|
} else if (!av_strcasecmp(cmd, "VideoIntraOnly")) {
|
998
|
|
- if (av_dict_set(&config->video_conf, "VideoGopSize", "1", 0) < 0)
|
|
992
|
+ if (ffserver_save_avoption("g", "1", AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
999
|
993
|
goto nomem;
|
1000
|
994
|
} else if (!av_strcasecmp(cmd, "VideoHighQuality")) {
|
1001
|
|
- if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
|
|
995
|
+ if (ffserver_save_avoption("mbd", "+bits", AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1002
|
996
|
goto nomem;
|
1003
|
997
|
} else if (!av_strcasecmp(cmd, "Video4MotionVector")) {
|
1004
|
|
- if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
|
|
998
|
+ if (ffserver_save_avoption("mbd", "+bits", AV_OPT_FLAG_VIDEO_PARAM, config) < 0 || //FIXME remove
|
|
999
|
+ ffserver_save_avoption("flags", "+mv4", AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1005
|
1000
|
goto nomem;
|
1006
|
1001
|
} else if (!av_strcasecmp(cmd, "AVOptionVideo") ||
|
1007
|
1002
|
!av_strcasecmp(cmd, "AVOptionAudio")) {
|
...
|
...
|
@@ -1023,52 +935,46 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
|
1023
|
1023
|
ffserver_opt_preset(arg, AV_OPT_FLAG_AUDIO_PARAM, config);
|
1024
|
1024
|
} else if (!av_strcasecmp(cmd, "VideoTag")) {
|
1025
|
1025
|
ffserver_get_arg(arg, sizeof(arg), p);
|
1026
|
|
- if (strlen(arg) == 4) {
|
1027
|
|
- if (av_dict_set(&config->video_conf, "VideoTag", arg, 0) < 0)
|
1028
|
|
- goto nomem;
|
1029
|
|
- }
|
|
1026
|
+ if (strlen(arg) == 4 &&
|
|
1027
|
+ ffserver_save_avoption_int("codec_tag", MKTAG(arg[0], arg[1], arg[2], arg[3]),
|
|
1028
|
+ AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
|
1029
|
+ goto nomem;
|
1030
|
1030
|
} else if (!av_strcasecmp(cmd, "BitExact")) {
|
1031
|
|
- if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
|
|
1031
|
+ if (ffserver_save_avoption("flags", "+bitexact", AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1032
|
1032
|
goto nomem;
|
1033
|
1033
|
} else if (!av_strcasecmp(cmd, "DctFastint")) {
|
1034
|
|
- if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
|
|
1034
|
+ if (ffserver_save_avoption("dct", "fastint", AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1035
|
1035
|
goto nomem;
|
1036
|
1036
|
} else if (!av_strcasecmp(cmd, "IdctSimple")) {
|
1037
|
|
- if (av_dict_set(&config->video_conf, cmd, "", 0) < 0)
|
|
1037
|
+ if (ffserver_save_avoption("idct", "simple", AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1038
|
1038
|
goto nomem;
|
1039
|
1039
|
} else if (!av_strcasecmp(cmd, "Qscale")) {
|
1040
|
1040
|
ffserver_get_arg(arg, sizeof(arg), p);
|
1041
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
1041
|
+ ffserver_set_int_param(&val, arg, 0, INT_MIN, INT_MAX, config,
|
|
1042
|
+ "Invalid Qscale: %s\n", arg);
|
|
1043
|
+ if (ffserver_save_avoption("flags", "+qscale", AV_OPT_FLAG_VIDEO_PARAM, config) < 0 ||
|
|
1044
|
+ ffserver_save_avoption_int("global_quality", FF_QP2LAMBDA * val,
|
|
1045
|
+ AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1042
|
1046
|
goto nomem;
|
1043
|
1047
|
} else if (!av_strcasecmp(cmd, "VideoQDiff")) {
|
1044
|
1048
|
ffserver_get_arg(arg, sizeof(arg), p);
|
1045
|
|
- ffserver_set_int_param(NULL, arg, 0, 1, 31, config,
|
1046
|
|
- "%s out of range\n", cmd);
|
1047
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
1049
|
+ if (ffserver_save_avoption("qdiff", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1048
|
1050
|
goto nomem;
|
1049
|
1051
|
} else if (!av_strcasecmp(cmd, "VideoQMax")) {
|
1050
|
1052
|
ffserver_get_arg(arg, sizeof(arg), p);
|
1051
|
|
- ffserver_set_int_param(NULL, arg, 0, 1, 31, config,
|
1052
|
|
- "%s out of range\n", cmd);
|
1053
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
1053
|
+ if (ffserver_save_avoption("qmax", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1054
|
1054
|
goto nomem;
|
1055
|
1055
|
} else if (!av_strcasecmp(cmd, "VideoQMin")) {
|
1056
|
1056
|
ffserver_get_arg(arg, sizeof(arg), p);
|
1057
|
|
- ffserver_set_int_param(NULL, arg, 0, 1, 31, config,
|
1058
|
|
- "%s out of range\n", cmd);
|
1059
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
1057
|
+ if (ffserver_save_avoption("qmin", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1060
|
1058
|
goto nomem;
|
1061
|
1059
|
} else if (!av_strcasecmp(cmd, "LumiMask")) {
|
1062
|
1060
|
ffserver_get_arg(arg, sizeof(arg), p);
|
1063
|
|
- ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config,
|
1064
|
|
- "Invalid %s: %s", cmd, arg);
|
1065
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
1061
|
+ if (ffserver_save_avoption("lumi_mask", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1066
|
1062
|
goto nomem;
|
1067
|
1063
|
} else if (!av_strcasecmp(cmd, "DarkMask")) {
|
1068
|
1064
|
ffserver_get_arg(arg, sizeof(arg), p);
|
1069
|
|
- ffserver_set_float_param(NULL, arg, 0, -FLT_MAX, FLT_MAX, config,
|
1070
|
|
- "Invalid %s: %s", cmd, arg);
|
1071
|
|
- if (av_dict_set(&config->video_conf, cmd, arg, 0) < 0)
|
|
1065
|
+ if (ffserver_save_avoption("dark_mask", arg, AV_OPT_FLAG_VIDEO_PARAM, config) < 0)
|
1072
|
1066
|
goto nomem;
|
1073
|
1067
|
} else if (!av_strcasecmp(cmd, "NoVideo")) {
|
1074
|
1068
|
config->no_video = 1;
|
...
|
...
|
@@ -1107,21 +1013,19 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
|
1107
|
1107
|
config->dummy_actx->codec_id = config->guessed_audio_codec_id;
|
1108
|
1108
|
if (!config->no_audio && config->dummy_actx->codec_id != AV_CODEC_ID_NONE) {
|
1109
|
1109
|
AVCodecContext *audio_enc = avcodec_alloc_context3(avcodec_find_encoder(config->dummy_actx->codec_id));
|
1110
|
|
- ffserver_apply_stream_config(audio_enc, config->audio_conf, &config->audio_opts);
|
|
1110
|
+ ffserver_apply_stream_config(audio_enc, &config->audio_opts);
|
1111
|
1111
|
add_codec(stream, audio_enc);
|
1112
|
1112
|
}
|
1113
|
1113
|
if (config->dummy_vctx->codec_id == AV_CODEC_ID_NONE)
|
1114
|
1114
|
config->dummy_vctx->codec_id = config->guessed_video_codec_id;
|
1115
|
1115
|
if (!config->no_video && config->dummy_vctx->codec_id != AV_CODEC_ID_NONE) {
|
1116
|
1116
|
AVCodecContext *video_enc = avcodec_alloc_context3(avcodec_find_encoder(config->dummy_vctx->codec_id));
|
1117
|
|
- ffserver_apply_stream_config(video_enc, config->video_conf, &config->video_opts);
|
|
1117
|
+ ffserver_apply_stream_config(video_enc, &config->video_opts);
|
1118
|
1118
|
add_codec(stream, video_enc);
|
1119
|
1119
|
}
|
1120
|
1120
|
}
|
1121
|
1121
|
av_dict_free(&config->video_opts);
|
1122
|
|
- av_dict_free(&config->video_conf);
|
1123
|
1122
|
av_dict_free(&config->audio_opts);
|
1124
|
|
- av_dict_free(&config->audio_conf);
|
1125
|
1123
|
avcodec_free_context(&config->dummy_vctx);
|
1126
|
1124
|
avcodec_free_context(&config->dummy_actx);
|
1127
|
1125
|
*pstream = NULL;
|
...
|
...
|
@@ -1135,9 +1039,7 @@ static int ffserver_parse_config_stream(FFServerConfig *config, const char *cmd,
|
1135
|
1135
|
nomem:
|
1136
|
1136
|
av_log(NULL, AV_LOG_ERROR, "Out of memory. Aborting.\n");
|
1137
|
1137
|
av_dict_free(&config->video_opts);
|
1138
|
|
- av_dict_free(&config->video_conf);
|
1139
|
1138
|
av_dict_free(&config->audio_opts);
|
1140
|
|
- av_dict_free(&config->audio_conf);
|
1141
|
1139
|
avcodec_free_context(&config->dummy_vctx);
|
1142
|
1140
|
avcodec_free_context(&config->dummy_actx);
|
1143
|
1141
|
return AVERROR(ENOMEM);
|