Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fftools/ffmpeg: calculate the time interval to get the first decoded …
…frame

Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
  • Loading branch information
fulinjie committed Jul 3, 2021
1 parent 9583e66 commit 2aa4762
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion fftools/ffmpeg.c
Expand Up @@ -109,6 +109,9 @@
const char program_name[] = "ffmpeg";
const int program_birth_year = 2000;

int64_t program_start_time = 0;
int64_t got_output_time = 0;

static FILE *vstats_file;

const char *const forced_keyframes_const_names[] = {
Expand Down Expand Up @@ -2462,6 +2465,11 @@ static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_
if (!*got_output || ret < 0)
return ret;

if (got_output_time == 0) {
got_output_time = av_gettime_relative() - program_start_time;
av_log(NULL, AV_LOG_ERROR, "first time to got frame, it takes %lld us\n", got_output_time);
}

if(ist->top_field_first>=0)
decoded_frame->top_field_first = ist->top_field_first;

Expand Down Expand Up @@ -4220,13 +4228,16 @@ static int get_input_packet_mt(InputFile *f, AVPacket **pkt)
static int get_input_packet(InputFile *f, AVPacket **pkt)
{
if (f->rate_emu) {
av_log(NULL, AV_LOG_INFO, "get_input_packet here.\n");
int i;
for (i = 0; i < f->nb_streams; i++) {
InputStream *ist = input_streams[f->ist_index + i];
int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
int64_t now = av_gettime_relative() - ist->start;
if (pts > now)
if (pts > now) {
av_log(NULL, AV_LOG_INFO, "pts > now, return EAGAIN.\n");
return AVERROR(EAGAIN);
}
}
}

Expand Down Expand Up @@ -4970,6 +4981,8 @@ int main(int argc, char **argv)

init_dynload();

program_start_time = av_gettime_relative();

register_exit(ffmpeg_cleanup);

setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
Expand Down

0 comments on commit 2aa4762

Please sign in to comment.