compensate pause in fps calculation

This commit is contained in:
mrbesen 2020-05-11 13:18:04 +02:00
parent 850482faf8
commit 5604fc76b5
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 14 additions and 8 deletions

View File

@ -1730,8 +1730,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
last_time = cur_time;
}
t = (cur_time-timer_start) / 1000000.0;
t = (cur_time - timer_start) / 1000000.0; //time in seconds, the transcode process is running
oc = output_files[0]->ctx;
@ -1758,7 +1757,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
float fps;
frame_number = ost->frame_number;
fps = t > 1 ? frame_number / t : 0;
fps = t > 0 ? frame_number / t : 0;
av_bprintf(&buf, "frame=%5d fps=%3.*f q=%3.1f ",
frame_number, fps < 9.95, fps, q);
av_bprintf(&buf_script, "frame=%d\n", frame_number);
@ -1901,8 +1900,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
time_t time = mktime(timeinfo);
time_t timef = time + secs;
time_t time = mktime(timeinfo); //current time
time_t timef = time + secs; //time finished
timeinfo = localtime(&timef);
secs %= 60;
@ -1912,7 +1911,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
else
strftime(timebuf, 20, "%T", timeinfo); //time only
av_bprintf(&buf, "Remaining=%"PRId64" ETA=%02d:%02d:%02d finish=%s", remaining_frames, hours, mins, secs, timebuf);
}
if (print_stats || is_last_report) {
@ -4808,7 +4809,7 @@ static int transcode(void)
#endif
while (!received_sigterm) {
int64_t cur_time= av_gettime_relative();
int64_t cur_time = av_gettime_relative();
/* if 'q' pressed, exits */
if (stdin_interaction) {
@ -4816,12 +4817,17 @@ static int transcode(void)
if (kbinteractionresult < 0)
break;
if(kbinteractionresult == 1) { //pause
fprintf(stderr, "Paused\r");
fprintf(stderr, "\033[101mPaused\033[0m\r");
//wait for key
getchar();
int64_t new_cur_time = av_gettime_relative();
int64_t paused = new_cur_time - cur_time;
cur_time = new_cur_time;
timer_start += paused; // shift the transcode start by the time, that was paused -> fix calculation of remaining and fps
fprintf(stderr, "Unpaused\r");
fprintf(stderr, "Unpaused Paused For: %lis \n", (paused / 1000000));
}
}