[FFmpeg-devel] [PATCH] ffmpeg: use avformat_seek_file() instead of av_seek_frame().

Clément Bœsch ubitux at gmail.com
Sat Nov 24 18:58:40 CET 2012


On Sat, Nov 24, 2012 at 01:13:55AM +0100, Michael Niedermayer wrote:
> On Fri, Nov 23, 2012 at 11:51:57PM +0100, Clément Bœsch wrote:
> > On Fri, Nov 23, 2012 at 10:13:13PM +0100, Michael Niedermayer wrote:
> > > On Fri, Nov 23, 2012 at 09:13:05PM +0100, Clément Bœsch wrote:
> > > > avformat_seek_file() is the new API. It will make sure the read_seek2()
> > > > callback is called when the demuxer has it.
> > > > ---
> > > >  ffmpeg_opt.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
> > > > index 09b4aaf..ad808ff 100644
> > > > --- a/ffmpeg_opt.c
> > > > +++ b/ffmpeg_opt.c
> > > > @@ -807,7 +807,7 @@ static int opt_input_file(void *optctx, const char *opt, const char *filename)
> > > >  
> > > >      /* if seeking requested, we execute it */
> > > >      if (o->start_time != 0) {
> > > > -        ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
> > > > +        ret = avformat_seek_file(ic, -1, INT64_MIN, timestamp, INT64_MAX, 0);
> > > 
> > > these are not equivalent.
> > > 
> > > Also currently if one seeks to X the seek favor backward seeking and
> > > can together with skiping everything before X give exact seeking.
> > > so the backward favoring should be kept in this case i think
> > > 
> > 
> > OK, replaced locally the 0 into AVSEEK_FLAG_BACKWARD.
> 
> the max ts should be set equal to timestamp
> something like:
> avformat_seek_file(ic, -1, INT64_MIN, timestamp, timestamp, 0);
> 

Blocking forward seeking with maxts, fun.

-- 
Clément B.
-------------- next part --------------
From 8175e42de02b391df5c2e6a46a4cdbfae2877454 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Fri, 23 Nov 2012 21:11:49 +0100
Subject: [PATCH] ffmpeg: use avformat_seek_file() instead of av_seek_frame().
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

avformat_seek_file() is the new API. It will make sure the read_seek2()
callback is called when the demuxer has it.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
Signed-off-by: Clément Bœsch <ubitux at gmail.com>
---
 ffmpeg_opt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 09b4aaf..2d94246 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -807,7 +807,7 @@ static int opt_input_file(void *optctx, const char *opt, const char *filename)
 
     /* if seeking requested, we execute it */
     if (o->start_time != 0) {
-        ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
+        ret = avformat_seek_file(ic, -1, INT64_MIN, timestamp, timestamp, 0);
         if (ret < 0) {
             av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",
                    filename, (double)timestamp / AV_TIME_BASE);
-- 
1.8.0

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121124/03b14bbe/attachment.asc>


More information about the ffmpeg-devel mailing list