X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fflags.cpp;h=ed52dc8933fba1f36a1a05c75f8ef85fae7d0691;hb=f9024d141398e69e7b4011becd3ebbe37eaa1776;hp=b025076c0639361fd74307a99af986582e089999;hpb=9ffd4f03f314cc6e0254449593def95c9bc203d6;p=nageru diff --git a/nageru/flags.cpp b/nageru/flags.cpp index b025076..ed52dc8 100644 --- a/nageru/flags.cpp +++ b/nageru/flags.cpp @@ -37,6 +37,7 @@ enum LongOption { OPTION_HTTP_AUDIO_BITRATE, OPTION_HTTP_PORT, OPTION_NO_TRANSCODE_AUDIO, + OPTION_DISABLE_AUDIO, OPTION_FLAT_AUDIO, OPTION_GAIN_STAGING, OPTION_DISABLE_LOCUT, @@ -87,7 +88,7 @@ map parse_mjpeg_export_cards(char *optarg) } if (range_end < range_begin) { fprintf(stderr, "ERROR: Invalid range %u-%u in --mjpeg-export-cards=\n", range_begin, range_end); - abort(); + exit(1); } if (range_end >= unsigned(global_flags.num_cards)) { // There are situations where we could possibly want to @@ -96,12 +97,12 @@ map parse_mjpeg_export_cards(char *optarg) // require more functionality the the JPEG encoder. fprintf(stderr, "ERROR: Asked for (zero-indexed) card %u in --mjpeg-export-cards=, but there are only %u cards\n", range_end, global_flags.num_cards); - abort(); + exit(1); } for (unsigned card_idx = range_begin; card_idx <= range_end; ++card_idx) { if (ret.count(card_idx)) { fprintf(stderr, "ERROR: Card %u was given twice in --mjpeg-export-cards=\n", card_idx); - abort(); + exit(1); } ret[card_idx] = stream_idx++; } @@ -170,6 +171,7 @@ void usage(Program program) if (program == PROGRAM_KAERU) { fprintf(stderr, " --no-transcode-audio copy encoded audio raw from the source stream\n"); fprintf(stderr, " (requires --http-audio-codec= to be set)\n"); + fprintf(stderr, " --disable-audio do not include any audio in the stream\n"); } if (program == PROGRAM_NAGERU) { fprintf(stderr, " --flat-audio start with most audio processing turned off\n"); @@ -252,6 +254,7 @@ void parse_flags(Program program, int argc, char * const argv[]) { "http-audio-bitrate", required_argument, 0, OPTION_HTTP_AUDIO_BITRATE }, { "http-port", required_argument, 0, OPTION_HTTP_PORT }, { "no-transcode-audio", no_argument, 0, OPTION_NO_TRANSCODE_AUDIO }, + { "disable-audio", no_argument, 0, OPTION_DISABLE_AUDIO }, { "flat-audio", no_argument, 0, OPTION_FLAT_AUDIO }, { "gain-staging", required_argument, 0, OPTION_GAIN_STAGING }, { "disable-locut", no_argument, 0, OPTION_DISABLE_LOCUT }, @@ -286,7 +289,7 @@ void parse_flags(Program program, int argc, char * const argv[]) bool card_to_mjpeg_stream_export_set = false; for ( ;; ) { int option_index = 0; - int c = getopt_long(argc, argv, "c:t:I:r:v:m:M:w:h:", long_options, &option_index); + int c = getopt_long(argc, argv, "c:o:t:I:r:v:m:M:w:h:", long_options, &option_index); if (c == -1) { break; @@ -317,7 +320,7 @@ void parse_flags(Program program, int argc, char * const argv[]) char *ptr = strchr(optarg, ','); if (ptr == nullptr) { fprintf(stderr, "ERROR: Invalid argument '%s' to --map-signal (needs a signal and a card number, separated by comma)\n", optarg); - abort(); + exit(1); } *ptr = '\0'; const int signal_num = atoi(optarg); @@ -325,7 +328,7 @@ void parse_flags(Program program, int argc, char * const argv[]) if (global_flags.default_stream_mapping.count(signal_num)) { fprintf(stderr, "ERROR: Signal %d already mapped to card %d\n", signal_num, global_flags.default_stream_mapping[signal_num]); - abort(); + exit(1); } global_flags.default_stream_mapping[signal_num] = card_num; break; @@ -367,6 +370,10 @@ void parse_flags(Program program, int argc, char * const argv[]) case OPTION_NO_TRANSCODE_AUDIO: global_flags.transcode_audio = false; break; + case OPTION_DISABLE_AUDIO: + global_flags.transcode_audio = false; + global_flags.enable_audio = false; + break; case OPTION_HTTP_X264_VIDEO: global_flags.x264_video_to_http = true; break; @@ -489,13 +496,13 @@ void parse_flags(Program program, int argc, char * const argv[]) char *ptr = strchr(optarg, ','); if (ptr == nullptr) { fprintf(stderr, "ERROR: Invalid argument '%s' to --input-ycbcr-interpretation (needs a card and an interpretation, separated by comma)\n", optarg); - abort(); + exit(1); } *ptr = '\0'; const int card_num = atoi(optarg); if (card_num < 0 || card_num >= MAX_VIDEO_CARDS) { fprintf(stderr, "ERROR: Invalid card number %d\n", card_num); - abort(); + exit(1); } YCbCrInterpretation interpretation; @@ -510,7 +517,7 @@ void parse_flags(Program program, int argc, char * const argv[]) interpretation.full_range = false; } else { fprintf(stderr, "ERROR: Invalid Y'CbCr range '%s' (must be “full” or “limited”)\n", range); - abort(); + exit(1); } } @@ -524,11 +531,11 @@ void parse_flags(Program program, int argc, char * const argv[]) interpretation.ycbcr_coefficients_auto = true; if (interpretation.full_range) { fprintf(stderr, "ERROR: Cannot use “auto” Y'CbCr coefficients with full range\n"); - abort(); + exit(1); } } else { fprintf(stderr, "ERROR: Invalid Y'CbCr coefficients '%s' (must be “rec601”, “rec709” or “auto”)\n", interpretation_str); - abort(); + exit(1); } global_flags.ycbcr_interpretation[card_num] = interpretation; break; @@ -539,7 +546,7 @@ void parse_flags(Program program, int argc, char * const argv[]) case OPTION_MJPEG_EXPORT_CARDS: { if (card_to_mjpeg_stream_export_set) { fprintf(stderr, "ERROR: --mjpeg-export-cards given twice\n"); - abort(); + exit(1); } global_flags.card_to_mjpeg_stream_export = parse_mjpeg_export_cards(optarg); card_to_mjpeg_stream_export_set = true; @@ -552,28 +559,28 @@ void parse_flags(Program program, int argc, char * const argv[]) fprintf(stderr, "Unknown option '%s'\n", argv[option_index]); fprintf(stderr, "\n"); usage(program); - abort(); + exit(1); } } if (global_flags.uncompressed_video_to_http && global_flags.x264_video_to_http) { fprintf(stderr, "ERROR: --http-uncompressed-video and --http-x264-video are mutually incompatible\n"); - abort(); + exit(1); } if (global_flags.num_cards <= 0) { fprintf(stderr, "ERROR: --num-cards must be at least 1\n"); - abort(); + exit(1); } if (global_flags.output_card < -1 || global_flags.output_card >= global_flags.num_cards) { fprintf(stderr, "ERROR: --output-card points to a nonexistant card\n"); - abort(); + exit(1); } - if (!global_flags.transcode_audio && global_flags.stream_audio_codec_name.empty()) { + if (global_flags.enable_audio && !global_flags.transcode_audio && global_flags.stream_audio_codec_name.empty()) { fprintf(stderr, "ERROR: If not transcoding audio, you must specify ahead-of-time what audio codec is in use\n"); fprintf(stderr, " (using --http-audio-codec).\n"); - abort(); + exit(1); } if (global_flags.x264_speedcontrol) { if (!global_flags.x264_preset.empty() && global_flags.x264_preset != "faster") { @@ -594,14 +601,14 @@ void parse_flags(Program program, int argc, char * const argv[]) if (global_flags.width <= 0 || (global_flags.width % 8) != 0 || global_flags.height <= 0 || (global_flags.height % 8) != 0) { fprintf(stderr, "ERROR: --width and --height must be positive integers divisible by 8\n"); - abort(); + exit(1); } for (pair mapping : global_flags.default_stream_mapping) { if (mapping.second >= global_flags.num_cards) { fprintf(stderr, "ERROR: Signal %d mapped to card %d, which doesn't exist (try adjusting --num-cards)\n", mapping.first, mapping.second); - abort(); + exit(1); } } @@ -633,22 +640,22 @@ void parse_flags(Program program, int argc, char * const argv[]) global_flags.ycbcr_auto_coefficients = false; } else { fprintf(stderr, "ERROR: --output-ycbcr-coefficients must be “rec601”, “rec709” or “auto”\n"); - abort(); + exit(1); } if (global_flags.output_buffer_frames < 0.0f) { // Actually, even zero probably won't make sense; there is some internal // delay to the card. fprintf(stderr, "ERROR: --output-buffer-frames can't be negative.\n"); - abort(); + exit(1); } if (global_flags.output_slop_frames < 0.0f) { fprintf(stderr, "ERROR: --output-slop-frames can't be negative.\n"); - abort(); + exit(1); } if (global_flags.max_input_queue_frames < 1) { fprintf(stderr, "ERROR: --max-input-queue-frames must be at least 1.\n"); - abort(); + exit(1); } if (global_flags.max_input_queue_frames > 10) { fprintf(stderr, "WARNING: --max-input-queue-frames has little effect over 10.\n"); @@ -657,7 +664,7 @@ void parse_flags(Program program, int argc, char * const argv[]) if (!isinf(global_flags.x264_crf)) { // CRF mode is selected. if (global_flags.x264_bitrate != -1) { fprintf(stderr, "ERROR: --x264-bitrate and --x264-crf are mutually incompatible.\n"); - abort(); + exit(1); } if (global_flags.x264_vbv_max_bitrate != -1 && global_flags.x264_vbv_buffer_size != -1) { fprintf(stderr, "WARNING: VBV settings are ignored with --x264-crf.\n");