From 3ff4da87a0b4ad742b436e6534b3217623824ff4 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 31 Jan 2013 17:10:48 +0100 Subject: video-decode: Add seek function --- src/video_decode.c | 12 ++++++++++++ src/video_decode.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/video_decode.c b/src/video_decode.c index ea23aea..7ce6f42 100644 --- a/src/video_decode.c +++ b/src/video_decode.c @@ -99,6 +99,18 @@ video_decode_uninit(struct video_decode **_vd) free(vd); } +int +video_decode_seek(struct video_decode *_vd, int64_t timestamp) +{ + struct video_decode_priv *vd = (struct video_decode_priv *) _vd; + + if (vd->fmt_ctx->start_time != AV_NOPTS_VALUE) + timestamp += vd->fmt_ctx->start_time; + + return avformat_seek_file(vd->fmt_ctx, vd->stream, + INT64_MIN, timestamp, INT64_MAX,0); +} + int video_decode_get_frame(struct video_decode *_vd, struct video_frame **frame) { diff --git a/src/video_decode.h b/src/video_decode.h index 3261b76..bd2c558 100644 --- a/src/video_decode.h +++ b/src/video_decode.h @@ -18,6 +18,9 @@ video_decode_init(struct video_decode **vd, char *file, int64_t timestamp); void video_decode_uninit(struct video_decode **vd); +int +video_decode_seek(struct video_decode *_vd, int64_t timestamp); + /* * Returns number of decoded frames: * 1 - One frame decoded -- cgit