Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2013-10-27 18:55:42 +0400
committerMarton Balint <cus@passwd.hu>2013-11-06 00:27:07 +0400
commit61dd31977066b00ff64cb4f6c7116f65def4882b (patch)
treee9969acaa13de939bc005782545d6c0f8b43aed3 /ffplay.c
parent105d4748cfc08bef7e0ab9f2be39a9777f985ccc (diff)
ffplay: add frame duration estimated from frame rate to VideoPicture
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ffplay.c b/ffplay.c
index cd14428d7a..e4fbdd4df5 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -121,6 +121,7 @@ typedef struct PacketQueue {
typedef struct VideoPicture {
double pts; // presentation timestamp for this picture
+ double duration; // estimated duration based on frame rate
int64_t pos; // byte position in file
SDL_Overlay *bmp;
int width, height; /* source height & width */
@@ -1549,7 +1550,7 @@ static void duplicate_right_border_pixels(SDL_Overlay *bmp) {
}
}
-static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t pos, int serial)
+static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, double duration, int64_t pos, int serial)
{
VideoPicture *vp;
@@ -1646,6 +1647,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t
SDL_UnlockYUVOverlay(vp->bmp);
vp->pts = pts;
+ vp->duration = duration;
vp->pos = pos;
vp->serial = serial;
@@ -1909,9 +1911,11 @@ static int video_thread(void *arg)
VideoState *is = arg;
AVFrame *frame = av_frame_alloc();
double pts;
+ double duration;
int ret;
int serial = 0;
AVRational tb = is->video_st->time_base;
+ AVRational frame_rate = av_guess_frame_rate(is->ic, is->video_st, NULL);
#if CONFIG_AVFILTER
AVFilterGraph *graph = avfilter_graph_alloc();
@@ -1962,6 +1966,7 @@ static int video_thread(void *arg)
last_h = frame->height;
last_format = frame->format;
last_serial = serial;
+ frame_rate = filt_out->inputs[0]->frame_rate;
}
ret = av_buffersrc_add_frame(filt_in, frame);
@@ -1987,8 +1992,9 @@ static int video_thread(void *arg)
is->frame_last_filter_delay = 0;
tb = filt_out->inputs[0]->time_base;
#endif
+ duration = (frame_rate.num && frame_rate.den ? av_q2d((AVRational){frame_rate.den, frame_rate.num}) : 0);
pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(tb);
- ret = queue_picture(is, frame, pts, av_frame_get_pkt_pos(frame), serial);
+ ret = queue_picture(is, frame, pts, duration, av_frame_get_pkt_pos(frame), serial);
av_frame_unref(frame);
#if CONFIG_AVFILTER
}