diff options
-rw-r--r-- | src/video_decode.c | 12 | ||||
-rw-r--r-- | src/video_decode.h | 3 |
2 files changed, 15 insertions, 0 deletions
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 @@ -100,6 +100,18 @@ video_decode_uninit(struct video_decode **_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) { struct video_decode_priv *vd = (struct video_decode_priv *) _vd; 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 |