fprintf(stderr, " --help print usage information\n");
fprintf(stderr, " -w, --width output width in pixels (default 1280)\n");
fprintf(stderr, " -h, --height output height in pixels (default 720)\n");
+ fprintf(stderr, " -r, --frame-rate NUM[/NUM] output frame rate, as a float or fraction\n");
+ fprintf(stderr, " (default 60000/1001 ~= 59.94)\n");
fprintf(stderr, " --slow-down-input slow down input to realtime (default on if no\n");
fprintf(stderr, " source URL given)\n");
fprintf(stderr, " -q, --interpolation-quality N 0 = off\n");
{ "help", no_argument, 0, OPTION_HELP },
{ "width", required_argument, 0, 'w' },
{ "height", required_argument, 0, 'h' },
+ { "frame-rate", required_argument, 0, 'r' },
{ "slow-down-input", no_argument, 0, OPTION_SLOW_DOWN_INPUT },
{ "interpolation-quality", required_argument, 0, 'q' },
{ "working-directory", required_argument, 0, 'd' },
};
for ( ;; ) {
int option_index = 0;
- int c = getopt_long(argc, argv, "w:h:q:d:", long_options, &option_index);
+ int c = getopt_long(argc, argv, "w:h:r:q:d:", long_options, &option_index);
if (c == -1) {
break;
case 'h':
global_flags.height = atoi(optarg);
break;
+ case 'r': {
+ double num, den;
+ if (sscanf(optarg, "%lf/%lf", &num, &den) == 2) {
+ global_flags.output_framerate = num / den;
+ } else if (sscanf(optarg, "%lf", &num) == 1) {
+ global_flags.output_framerate = num;
+ } else {
+ fprintf(stderr, "Invalid frame rate given (must be on the form N or N/M)\n");
+ exit(1);
+ }
+ break;
+ }
case OPTION_SLOW_DOWN_INPUT:
global_flags.slow_down_input = true;
break;
check_error();
- constexpr double output_framerate = 60000.0 / 1001.0; // FIXME: make configurable
int64_t pts = 0;
Clip next_clip;
size_t next_clip_idx = size_t(-1);
int64_t in_pts_start_next_clip = -1;
steady_clock::time_point next_frame_start;
for (int frameno = 0; !should_quit; ++frameno) { // Ends when the clip ends.
- double out_pts = out_pts_origin + TIMEBASE * frameno / output_framerate;
+ double out_pts = out_pts_origin + TIMEBASE * frameno / global_flags.output_framerate;
next_frame_start =
origin + microseconds(lrint((out_pts - out_pts_origin) * 1e6 / TIMEBASE));
- int64_t in_pts = lrint(in_pts_origin + TIMEBASE * frameno * speed / output_framerate);
+ int64_t in_pts = lrint(in_pts_origin + TIMEBASE * frameno * speed / global_flags.output_framerate);
pts = lrint(out_pts);
if (in_pts >= clip.pts_out) {
// TODO: Snap secondary (fade-to) clips in the same fashion.
bool snapped = false;
for (FrameOnDisk snap_frame : { frame_lower, frame_upper }) {
- double snap_pts_as_frameno = (snap_frame.pts - in_pts_origin) * output_framerate / TIMEBASE / speed;
+ double snap_pts_as_frameno = (snap_frame.pts - in_pts_origin) * global_flags.output_framerate / TIMEBASE / speed;
if (fabs(snap_pts_as_frameno - frameno) < 0.01) {
auto display_func = [this, primary_stream_idx, snap_frame, secondary_frame, fade_alpha]{
if (destination != nullptr) {