int main(int argc, const char **argv) { bool output_set = false; bool output_timecode = false; bool drop_frame = false; Rational frame_rate = FRAME_RATE_25; const char *value_str = 0; int cmdln_index = 1; for (cmdln_index = 1; cmdln_index < argc; cmdln_index++) { if (strcmp(argv[cmdln_index], "--output") == 0) { if (cmdln_index + 1 >= argc) { usage(argv[0]); return 1; } if (strcmp(argv[cmdln_index + 1], "tc-drop") == 0) { output_timecode = true; drop_frame = true; } else if (strcmp(argv[cmdln_index + 1], "tc-non-drop") == 0) { output_timecode = true; drop_frame = false; } else if (strcmp(argv[cmdln_index + 1], "count") == 0) { output_timecode = false; } else { usage(argv[0]); return 1; } output_set = true; cmdln_index++; } else if (strcmp(argv[cmdln_index], "--rate") == 0) { if (cmdln_index + 1 >= argc) { usage(argv[0]); return 1; } if (!::parse_frame_rate(argv[cmdln_index + 1], &frame_rate)) { usage(argv[0]); return 1; } cmdln_index++; } else { break; } } if (cmdln_index + 1 != argc) { usage(argv[0]); return 1; } if (strcmp(argv[cmdln_index], "all") != 0) value_str = argv[cmdln_index]; if (value_str) { Timecode timecode; if (parse_timecode(value_str, frame_rate, &timecode)) { if (!output_set) output_timecode = false; if (output_timecode) timecode.Init(frame_rate, drop_frame, timecode.GetOffset()); } else { int64_t offset; if (sscanf(value_str, "%" PRId64, &offset) != 1) { fprintf(stderr, "Failed to parse timecode or frame offset\n"); return 1; } timecode.Init(frame_rate, drop_frame, offset); if (!output_set) output_timecode = true; } if (output_timecode) printf("%s\n", get_timecode_string(timecode).c_str()); else printf("%" PRId64 "\n", timecode.GetOffset()); } else { Timecode timecode(frame_rate, drop_frame, 0); int64_t max_offset = timecode.GetMaxOffset(); int64_t i; for (i = 0; i < max_offset; i++) { timecode.Init(frame_rate, drop_frame, i); printf("%8" PRId64 ": %s\n", i, get_timecode_string(timecode).c_str()); } } return 0; }