X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=flags.cpp;h=f7a29f7330eb34f218d1146c97ddf438b7441352;hb=14dc6f7ef9dd76cba75ffe7499d9a81d66c7b152;hp=9c91bf7bee2cd7c269fd21a3566e073a5ba16266;hpb=7f726d57e80de3e18686f0e45482ca48db91e82f;p=nageru diff --git a/flags.cpp b/flags.cpp index 9c91bf7..f7a29f7 100644 --- a/flags.cpp +++ b/flags.cpp @@ -19,11 +19,13 @@ enum LongOption { OPTION_FAKE_CARDS_AUDIO, OPTION_HTTP_UNCOMPRESSED_VIDEO, OPTION_HTTP_X264_VIDEO, + OPTION_RECORD_X264_VIDEO, OPTION_X264_PRESET, OPTION_X264_TUNE, OPTION_X264_SPEEDCONTROL, OPTION_X264_SPEEDCONTROL_VERBOSE, OPTION_X264_BITRATE, + OPTION_X264_CRF, OPTION_X264_VBV_BUFSIZE, OPTION_X264_VBV_MAX_BITRATE, OPTION_X264_PARAM, @@ -53,6 +55,8 @@ enum LongOption { OPTION_OUTPUT_SLOP_FRAMES, OPTION_TIMECODE_STREAM, OPTION_TIMECODE_STDOUT, + OPTION_10_BIT_INPUT, + OPTION_10_BIT_OUTPUT, }; void usage() @@ -66,6 +70,7 @@ void usage() fprintf(stderr, " -o, --output-card=CARD also output signal to the given card (default none)\n"); fprintf(stderr, " -t, --theme=FILE choose theme (default theme.lua)\n"); fprintf(stderr, " -I, --theme-dir=DIR search for theme in this directory (can be given multiple times)\n"); + fprintf(stderr, " -r, --recording-dir=DIR where to store disk recording\n"); fprintf(stderr, " -v, --va-display=SPEC VA-API device for H.264 encoding\n"); fprintf(stderr, " ($DISPLAY spec or /dev/dri/render* path)\n"); fprintf(stderr, " -m, --map-signal=SIGNAL,CARD set a default card mapping (can be given multiple times)\n"); @@ -75,12 +80,15 @@ void usage() fprintf(stderr, " --fake-cards-audio make fake (disconnected) cards output a simple tone\n"); fprintf(stderr, " --http-uncompressed-video send uncompressed NV12 video to HTTP clients\n"); fprintf(stderr, " --http-x264-video send x264-compressed video to HTTP clients\n"); + fprintf(stderr, " --record-x264-video store x264-compressed video to disk (implies --http-x264-video,\n"); + fprintf(stderr, " removes the need for working VA-API encoding)\n"); fprintf(stderr, " --x264-preset x264 quality preset (default " X264_DEFAULT_PRESET ")\n"); fprintf(stderr, " --x264-tune x264 tuning (default " X264_DEFAULT_TUNE ", can be blank)\n"); fprintf(stderr, " --x264-speedcontrol try to match x264 preset to available CPU speed\n"); fprintf(stderr, " --x264-speedcontrol-verbose output speedcontrol debugging statistics\n"); fprintf(stderr, " --x264-bitrate x264 bitrate (in kilobit/sec, default %d)\n", DEFAULT_X264_OUTPUT_BIT_RATE); + fprintf(stderr, " --x264-crf=VALUE quality-based VBR (-12 to 51), incompatible with --x264-bitrate and VBV\n"); fprintf(stderr, " --x264-vbv-bufsize x264 VBV size (in kilobits, 0 = one-frame VBV,\n"); fprintf(stderr, " default: same as --x264-bitrate, that is, one-second VBV)\n"); fprintf(stderr, " --x264-vbv-max-bitrate x264 local max bitrate (in kilobit/sec per --vbv-bufsize,\n"); @@ -113,8 +121,8 @@ void usage() fprintf(stderr, " --audio-queue-length-ms=MS length of audio resampling queue (default 100.0)\n"); fprintf(stderr, " --output-ycbcr-coefficients={rec601,rec709,auto}\n"); fprintf(stderr, " Y'CbCr coefficient standard of output (default auto)\n"); - fprintf(stderr, " auto is rec709 if and only if --output-card is used\n"); - fprintf(stderr, " and a HD resolution is set\n"); + fprintf(stderr, " auto is rec601, unless --output-card is used\n"); + fprintf(stderr, " and a Rec. 709 mode (typically HD modes) is in use\n"); fprintf(stderr, " --output-buffer-frames=NUM number of frames in output buffer for --output-card,\n"); fprintf(stderr, " can be fractional (default 6.0); note also\n"); fprintf(stderr, " the audio queue can't be much longer than this\n"); @@ -123,6 +131,9 @@ void usage() fprintf(stderr, " dropping the frame (default 0.5)\n"); fprintf(stderr, " --timecode-stream show timestamp and timecode in stream\n"); fprintf(stderr, " --timecode-stdout show timestamp and timecode on standard output\n"); + fprintf(stderr, " --10-bit-input use 10-bit video input (requires compute shaders)\n"); + fprintf(stderr, " --10-bit-output use 10-bit video output (requires compute shaders,\n"); + fprintf(stderr, " implies --record-x264-video)\n"); } void parse_flags(int argc, char * const argv[]) @@ -135,6 +146,7 @@ void parse_flags(int argc, char * const argv[]) { "output-card", required_argument, 0, 'o' }, { "theme", required_argument, 0, 't' }, { "theme-dir", required_argument, 0, 'I' }, + { "recording-dir", required_argument, 0, 'r' }, { "map-signal", required_argument, 0, 'm' }, { "input-mapping", required_argument, 0, 'M' }, { "va-display", required_argument, 0, 'v' }, @@ -143,11 +155,13 @@ void parse_flags(int argc, char * const argv[]) { "fake-cards-audio", no_argument, 0, OPTION_FAKE_CARDS_AUDIO }, { "http-uncompressed-video", no_argument, 0, OPTION_HTTP_UNCOMPRESSED_VIDEO }, { "http-x264-video", no_argument, 0, OPTION_HTTP_X264_VIDEO }, + { "record-x264-video", no_argument, 0, OPTION_RECORD_X264_VIDEO }, { "x264-preset", required_argument, 0, OPTION_X264_PRESET }, { "x264-tune", required_argument, 0, OPTION_X264_TUNE }, { "x264-speedcontrol", no_argument, 0, OPTION_X264_SPEEDCONTROL }, { "x264-speedcontrol-verbose", no_argument, 0, OPTION_X264_SPEEDCONTROL_VERBOSE }, { "x264-bitrate", required_argument, 0, OPTION_X264_BITRATE }, + { "x264-crf", required_argument, 0, OPTION_X264_CRF }, { "x264-vbv-bufsize", required_argument, 0, OPTION_X264_VBV_BUFSIZE }, { "x264-vbv-max-bitrate", required_argument, 0, OPTION_X264_VBV_MAX_BITRATE }, { "x264-param", required_argument, 0, OPTION_X264_PARAM }, @@ -177,13 +191,15 @@ void parse_flags(int argc, char * const argv[]) { "output-slop-frames", required_argument, 0, OPTION_OUTPUT_SLOP_FRAMES }, { "timecode-stream", no_argument, 0, OPTION_TIMECODE_STREAM }, { "timecode-stdout", no_argument, 0, OPTION_TIMECODE_STDOUT }, + { "10-bit-input", no_argument, 0, OPTION_10_BIT_INPUT }, + { "10-bit-output", no_argument, 0, OPTION_10_BIT_OUTPUT }, { 0, 0, 0, 0 } }; vector theme_dirs; string output_ycbcr_coefficients = "auto"; for ( ;; ) { int option_index = 0; - int c = getopt_long(argc, argv, "c:t:I:v:m:M:w:h:", long_options, &option_index); + int c = getopt_long(argc, argv, "c:t:I:r:v:m:M:w:h:", long_options, &option_index); if (c == -1) { break; @@ -207,6 +223,9 @@ void parse_flags(int argc, char * const argv[]) case 'I': theme_dirs.push_back(optarg); break; + case 'r': + global_flags.recording_dir = optarg; + break; case 'm': { char *ptr = strchr(optarg, ','); if (ptr == nullptr) { @@ -258,6 +277,10 @@ void parse_flags(int argc, char * const argv[]) case OPTION_HTTP_X264_VIDEO: global_flags.x264_video_to_http = true; break; + case OPTION_RECORD_X264_VIDEO: + global_flags.x264_video_to_disk = true; + global_flags.x264_video_to_http = true; + break; case OPTION_X264_PRESET: global_flags.x264_preset = optarg; break; @@ -273,6 +296,9 @@ void parse_flags(int argc, char * const argv[]) case OPTION_X264_BITRATE: global_flags.x264_bitrate = atoi(optarg); break; + case OPTION_X264_CRF: + global_flags.x264_crf = atof(optarg); + break; case OPTION_X264_VBV_BUFSIZE: global_flags.x264_vbv_buffer_size = atoi(optarg); break; @@ -354,6 +380,15 @@ void parse_flags(int argc, char * const argv[]) case OPTION_TIMECODE_STDOUT: global_flags.display_timecode_on_stdout = true; break; + case OPTION_10_BIT_INPUT: + global_flags.ten_bit_input = true; + break; + case OPTION_10_BIT_OUTPUT: + global_flags.ten_bit_output = true; + global_flags.x264_video_to_disk = true; + global_flags.x264_video_to_http = true; + global_flags.x264_bit_depth = 10; + break; case OPTION_HELP: usage(); exit(0); @@ -424,17 +459,17 @@ void parse_flags(int argc, char * const argv[]) // On the other hand, HDMI/SDI output typically requires Rec. 709 for // HD resolutions (with no way of signaling anything else), which is // a conflicting demand. In this case, we typically let the HDMI/SDI - // output win, but the user can override this. + // output win if it is active, but the user can override this. if (output_ycbcr_coefficients == "auto") { - if (global_flags.output_card >= 0 && global_flags.width >= 1280) { - global_flags.ycbcr_rec709_coefficients = true; - } else { - global_flags.ycbcr_rec709_coefficients = false; - } + // Essentially: BT.709 if HDMI/SDI output is on, otherwise BT.601. + global_flags.ycbcr_rec709_coefficients = false; + global_flags.ycbcr_auto_coefficients = true; } else if (output_ycbcr_coefficients == "rec709") { global_flags.ycbcr_rec709_coefficients = true; + global_flags.ycbcr_auto_coefficients = false; } else if (output_ycbcr_coefficients == "rec601") { global_flags.ycbcr_rec709_coefficients = false; + global_flags.ycbcr_auto_coefficients = false; } else { fprintf(stderr, "ERROR: --output-ycbcr-coefficients must be “rec601”, “rec709” or “auto”\n"); exit(1); @@ -457,4 +492,16 @@ void parse_flags(int argc, char * const argv[]) if (global_flags.max_input_queue_frames > 10) { fprintf(stderr, "WARNING: --max-input-queue-frames has little effect over 10.\n"); } + + 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"); + 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"); + } + } else if (global_flags.x264_bitrate == -1) { + global_flags.x264_bitrate = DEFAULT_X264_OUTPUT_BIT_RATE; + } }