12 int flow_initialized_interpolation_quality;
14 // Long options that have no corresponding short option.
17 OPTION_SLOW_DOWN_INPUT = 1001,
18 OPTION_HTTP_PORT = 1002,
19 OPTION_TALLY_URL = 1003,
20 OPTION_CUE_POINT_PADDING = 1004,
21 OPTION_MIDI_MAPPING = 1005
26 fprintf(stderr, "Usage: futatabi [OPTION]... SOURCE_URL\n");
27 fprintf(stderr, "\n");
28 fprintf(stderr, " --help print usage information\n");
29 fprintf(stderr, " -w, --width output width in pixels (default 1280)\n");
30 fprintf(stderr, " -h, --height output height in pixels (default 720)\n");
31 fprintf(stderr, " -r, --frame-rate NUM[/NUM] output frame rate, as a float or fraction\n");
32 fprintf(stderr, " (default 60000/1001 ~= 59.94)\n");
33 fprintf(stderr, " --slow-down-input slow down input to realtime (default on if no\n");
34 fprintf(stderr, " source URL given)\n");
35 fprintf(stderr, " -q, --interpolation-quality N 0 = off\n");
36 fprintf(stderr, " 1 = fastest\n");
37 fprintf(stderr, " 2 = default (realtime 720p on fast embedded GPUs)\n");
38 fprintf(stderr, " 3 = good (realtime 720p on GTX 970 or so)\n");
39 fprintf(stderr, " 4 = best (not realtime on any current GPU)\n");
40 fprintf(stderr, " --cue-point-padding SECS move cue-in/cue-out N seconds earlier/later on set\n");
41 fprintf(stderr, " -d, --working-directory DIR where to store frames and database\n");
42 fprintf(stderr, " --http-port PORT which port to listen on for output\n");
43 fprintf(stderr, " --tally-url URL URL to get tally color from (polled every 100 ms)\n");
44 fprintf(stderr, " --midi-mapping=FILE start with the given MIDI controller mapping\n");
47 void parse_flags(int argc, char *const argv[])
49 static const option long_options[] = {
50 { "help", no_argument, 0, OPTION_HELP },
51 { "width", required_argument, 0, 'w' },
52 { "height", required_argument, 0, 'h' },
53 { "frame-rate", required_argument, 0, 'r' },
54 { "slow-down-input", no_argument, 0, OPTION_SLOW_DOWN_INPUT },
55 { "interpolation-quality", required_argument, 0, 'q' },
56 { "working-directory", required_argument, 0, 'd' },
57 { "http-port", required_argument, 0, OPTION_HTTP_PORT },
58 { "tally-url", required_argument, 0, OPTION_TALLY_URL },
59 { "cue-point-padding", required_argument, 0, OPTION_CUE_POINT_PADDING },
60 { "midi-mapping", required_argument, 0, OPTION_MIDI_MAPPING },
65 int c = getopt_long(argc, argv, "w:h:r:q:d:", long_options, &option_index);
72 global_flags.width = atoi(optarg);
75 global_flags.height = atoi(optarg);
79 if (sscanf(optarg, "%lf/%lf", &num, &den) == 2) {
80 global_flags.output_framerate = num / den;
81 } else if (sscanf(optarg, "%lf", &num) == 1) {
82 global_flags.output_framerate = num;
84 fprintf(stderr, "Invalid frame rate given (must be on the form N or N/M)\n");
89 case OPTION_SLOW_DOWN_INPUT:
90 global_flags.slow_down_input = true;
93 global_flags.interpolation_quality = atoi(optarg);
94 global_flags.interpolation_quality_set = true;
97 global_flags.working_directory = optarg;
99 case OPTION_HTTP_PORT:
100 global_flags.http_port = atoi(optarg);
102 case OPTION_TALLY_URL:
103 global_flags.tally_url = optarg;
105 case OPTION_CUE_POINT_PADDING:
106 global_flags.cue_point_padding_seconds = atof(optarg);
107 global_flags.cue_point_padding_set = true;
109 case OPTION_MIDI_MAPPING:
110 global_flags.midi_mapping_filename = optarg;
116 fprintf(stderr, "Unknown option '%s'\n", argv[option_index]);
117 fprintf(stderr, "\n");
123 if (global_flags.interpolation_quality < 0 || global_flags.interpolation_quality > 4) {
124 fprintf(stderr, "Interpolation quality must be 0, 1, 2, 3 or 4.\n");
128 if (global_flags.cue_point_padding_seconds < 0.0) {
129 fprintf(stderr, "Cue point padding cannot be negative.\n");