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,
OPTION_TIMECODE_STDOUT,
OPTION_10_BIT_INPUT,
OPTION_10_BIT_OUTPUT,
+ OPTION_INPUT_YCBCR_INTERPRETATION,
};
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");
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");
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");
+ fprintf(stderr, " --input-ycbcr-interpretation=CARD,{rec601,rec709,auto}[,{limited,full}]\n");
+ fprintf(stderr, " Y'CbCr coefficient standard of card CARD (default auto)\n");
+ fprintf(stderr, " auto is rec601 for SD, rec709 for HD, always limited\n");
+ fprintf(stderr, " limited means standard 0-240/0-235 input range (for 8-bit)\n");
}
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' },
{ "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 },
{ "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 },
+ { "input-ycbcr-interpretation", required_argument, 0, OPTION_INPUT_YCBCR_INTERPRETATION },
{ 0, 0, 0, 0 }
};
vector<string> 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;
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) {
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;
global_flags.x264_video_to_http = true;
global_flags.x264_bit_depth = 10;
break;
+ case OPTION_INPUT_YCBCR_INTERPRETATION: {
+ 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);
+ 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);
+ exit(1);
+ }
+
+ YCbCrInterpretation interpretation;
+ char *interpretation_str = ptr + 1;
+ ptr = strchr(interpretation_str, ',');
+ if (ptr != nullptr) {
+ *ptr = '\0';
+ const char *range = ptr + 1;
+ if (strcmp(range, "full") == 0) {
+ interpretation.full_range = true;
+ } else if (strcmp(range, "limited") == 0) {
+ interpretation.full_range = false;
+ } else {
+ fprintf(stderr, "ERROR: Invalid Y'CbCr range '%s' (must be “full” or “limited”)\n", range);
+ exit(1);
+ }
+ }
+
+ if (strcmp(interpretation_str, "rec601") == 0) {
+ interpretation.ycbcr_coefficients_auto = false;
+ interpretation.ycbcr_coefficients = movit::YCBCR_REC_601;
+ } else if (strcmp(interpretation_str, "rec709") == 0) {
+ interpretation.ycbcr_coefficients_auto = false;
+ interpretation.ycbcr_coefficients = movit::YCBCR_REC_709;
+ } else if (strcmp(interpretation_str, "auto") == 0) {
+ interpretation.ycbcr_coefficients_auto = true;
+ if (interpretation.full_range) {
+ fprintf(stderr, "ERROR: Cannot use “auto” Y'CbCr coefficients with full range\n");
+ exit(1);
+ }
+ } else {
+ fprintf(stderr, "ERROR: Invalid Y'CbCr coefficients '%s' (must be “rec601”, “rec709” or “auto”)\n", interpretation_str);
+ exit(1);
+ }
+ global_flags.ycbcr_interpretation[card_num] = interpretation;
+ break;
+ }
case OPTION_HELP:
usage();
exit(0);
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;
+ }
}