int reduce_pts;
int vfr_input;
int num_frames;
+ int64_t time;
} ffms_hnd_t;
static int FFMS_CC update_progress( int64_t current, int64_t total, void *private )
{
- if( current % 10 )
+ int64_t *time = private;
+ int64_t oldtime = *time;
+ int64_t newtime = x264_mdate();
+ if( oldtime && newtime - oldtime < UPDATE_INTERVAL )
return 0;
+ *time = newtime;
+
char buf[200];
sprintf( buf, "ffms [info]: indexing input file [%.1f%%]", 100.0 * current / total );
fprintf( stderr, "%s \r", buf+5 );
}
if( !idx )
{
- idx = FFMS_MakeIndex( psz_filename, 0, 0, NULL, NULL, 0, update_progress, NULL, &e );
+ idx = FFMS_MakeIndex( psz_filename, 0, 0, NULL, NULL, 0, update_progress, &h->time, &e );
fprintf( stderr, " \r" );
FAIL_IF_ERROR( !idx, "could not create index\n" )
if( opt->index_file && FFMS_WriteIndex( opt->index_file, idx, &e ) )
return i_frame_size;
}
-static void print_status( int64_t i_start, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
+static int64_t print_status( int64_t i_start, int64_t i_previous, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
{
char buf[200];
- int64_t i_elapsed = x264_mdate() - i_start;
+ int64_t i_time = x264_mdate();
+ if( i_previous && i_time - i_previous < UPDATE_INTERVAL )
+ return i_previous;
+ int64_t i_elapsed = i_time - i_start;
double fps = i_elapsed > 0 ? i_frame * 1000000. / i_elapsed : 0;
double bitrate;
if( last_ts )
fprintf( stderr, "%s \r", buf+5 );
SetConsoleTitle( buf );
fflush( stderr ); // needed in windows
+ return i_time;
}
static void convert_cli_to_lib_pic( x264_picture_t *lib, cli_pic_t *cli )
int i_frame = 0;
int i_frame_output = 0;
- int64_t i_end, i_start = 0;
+ int64_t i_end, i_previous = 0, i_start = 0;
int64_t i_file = 0;
int i_frame_size;
- int i_update_interval;
int64_t last_dts = 0;
int64_t prev_dts = 0;
int64_t first_dts = 0;
GetConsoleTitle( originalCTitle, sizeof(originalCTitle) );
opt->b_progress &= param->i_log_level < X264_LOG_DEBUG;
- i_update_interval = param->i_frame_total ? x264_clip3( param->i_frame_total / 1000, 1, 10 ) : 10;
/* set up pulldown */
if( opt->i_pulldown && !param->b_vfr_input )
FAIL_IF_ERROR2( output.set_param( opt->hout, param ), "can't set outfile param\n" );
i_start = x264_mdate();
+
/* ticks/frame = ticks/second / frames/second */
ticks_per_frame = (int64_t)param->i_timebase_den * param->i_fps_den / param->i_timebase_num / param->i_fps_num;
FAIL_IF_ERROR2( ticks_per_frame < 1 && !param->b_vfr_input, "ticks_per_frame invalid: %"PRId64"\n", ticks_per_frame )
break;
/* update status line (up to 1000 times per input file) */
- if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
- print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
+ if( opt->b_progress && i_frame_output )
+ i_previous = print_status( i_start, i_previous, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
}
/* Flush delayed frames */
while( !b_ctrl_c && x264_encoder_delayed_frames( h ) )
if( i_frame_output == 1 )
first_dts = prev_dts = last_dts;
}
- if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
- print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
+ if( opt->b_progress && i_frame_output )
+ i_previous = print_status( i_start, i_previous, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
}
fail:
if( pts_warning_cnt >= MAX_PTS_WARNING && cli_log_level < X264_LOG_DEBUG )