Skip to content

Commit

Permalink
demos/plplay: print values only if they are available
Browse files Browse the repository at this point in the history
Insteand if printing big negative duration just skip it. Add TBR and TBN
print.
  • Loading branch information
kasper93 committed Feb 1, 2023
1 parent 20010a1 commit 06213bb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions demos/plplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ static bool open_file(struct plplay *p, const char *filename)
}

printf("Format: %s\n", p->format->iformat->name);
printf("Duration: %.3f s\n", p->format->duration / 1e6);

if (p->format->duration != AV_NOPTS_VALUE)
printf("Duration: %.3f s\n", p->format->duration / 1e6);

if (avformat_find_stream_info(p->format, NULL) < 0) {
fprintf(stderr, "libavformat: Failed finding stream info!\n");
Expand All @@ -158,8 +160,19 @@ static bool open_file(struct plplay *p, const char *filename)
const AVCodecParameters *par = stream->codecpar;
printf("Found video track (stream %d)\n", stream_idx);
printf("Resolution: %d x %d\n", par->width, par->height);
printf("FPS: %f\n", av_q2d(stream->avg_frame_rate));
printf("Bitrate: %"PRIi64" kbps\n", par->bit_rate / 1000);

if (stream->avg_frame_rate.den && stream->avg_frame_rate.num)
printf("FPS: %f\n", av_q2d(stream->avg_frame_rate));

if (stream->r_frame_rate.den && stream->r_frame_rate.num)
printf("TBR: %f\n", av_q2d(stream->r_frame_rate));

if (stream->time_base.den && stream->time_base.num)
printf("TBN: %f\n", av_q2d(stream->time_base));

if (par->bit_rate)
printf("Bitrate: %"PRIi64" kbps\n", par->bit_rate / 1000);

printf("Format: %s\n", av_get_pix_fmt_name(par->format));

p->stream = stream;
Expand Down

0 comments on commit 06213bb

Please sign in to comment.