[FFmpeg-devel] [PATCH] ffmpeg: Implement support for seeking relative to EOF

Michael Niedermayer michaelni at gmx.at
Mon Jul 27 04:30:26 CEST 2015


From: Michael Niedermayer <michael at niedermayer.cc>

Fixes Ticket227

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 ffmpeg.h     |    1 +
 ffmpeg_opt.c |    6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/ffmpeg.h b/ffmpeg.h
index e43c985..38e7784 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -92,6 +92,7 @@ typedef struct OptionsContext {
 
     /* input/output options */
     int64_t start_time;
+    int64_t start_time_eof;
     int seek_timestamp;
     const char *format;
 
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index ceebcfe..21477ed 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -156,6 +156,7 @@ static void init_options(OptionsContext *o)
     o->stop_time = INT64_MAX;
     o->mux_max_delay  = 0.7;
     o->start_time     = AV_NOPTS_VALUE;
+    o->start_time_eof = AV_NOPTS_VALUE;
     o->recording_time = INT64_MAX;
     o->limit_filesize = UINT64_MAX;
     o->chapters_input_file = INT_MAX;
@@ -933,6 +934,8 @@ static int open_input_file(OptionsContext *o, const char *filename)
         }
     }
 
+    if (o->start_time_eof != AV_NOPTS_VALUE && ic->duration>0)
+        o->start_time = o->start_time_eof + ic->duration;
     timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time;
     /* add the stream start time */
     if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE)
@@ -3019,6 +3022,9 @@ const OptionDef options[] = {
     { "ss",             HAS_ARG | OPT_TIME | OPT_OFFSET |
                         OPT_INPUT | OPT_OUTPUT,                      { .off = OFFSET(start_time) },
         "set the start time offset", "time_off" },
+    { "sseof",          HAS_ARG | OPT_TIME | OPT_OFFSET |
+                        OPT_INPUT | OPT_OUTPUT,                      { .off = OFFSET(start_time_eof) },
+        "set the start time offset relative to EOF", "time_off" },
     { "seek_timestamp", HAS_ARG | OPT_INT | OPT_OFFSET |
                         OPT_INPUT,                                   { .off = OFFSET(seek_timestamp) },
         "enable/disable seeking by timestamp with -ss" },
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list