[FFmpeg-devel] [PATCH] ffmpeg_opt: add -seek_error option
Simon Thelen
ffmpeg-dev at c-14.de
Wed Oct 8 19:13:33 CEST 2014
Enabling -seek_error causes ffmpeg to quit when it notices that
stop_time <= start_time.
Closes ticket #4015.
Signed-off-by: Simon Thelen <ffmpeg-dev at c-14.de>
---
doc/ffmpeg.texi | 4 ++++
ffmpeg_opt.c | 7 +++++++
2 files changed, 11 insertions(+)
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 4fc7682..4526605 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1144,6 +1144,10 @@ This option enables or disables accurate seeking in input files with the
transcoding. Use @option{-noaccurate_seek} to disable it, which may be useful
e.g. when copying some streams and transcoding the others.
+ at item -seek_err (@emph{global})
+This option causes @command{ffmpeg} to error out instead of continuing when
+ at option{-ss} is greater than @option{-to}. This option is disabled by default.
+
@item -override_ffserver (@emph{global})
Overrides the input specifications from @command{ffserver}. Using this
option you can map any input stream to @command{ffserver} and control
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 10aaa3a..49d71c2 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -94,6 +94,7 @@ int copy_ts = 0;
int copy_tb = -1;
int debug_ts = 0;
int exit_on_error = 0;
+int seek_error = 0;
int print_stats = -1;
int qp_hist = 0;
int stdin_interaction = 1;
@@ -1732,6 +1733,10 @@ static int open_output_file(OptionsContext *o, const char *filename)
if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) {
int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : o->start_time;
if (o->stop_time <= start_time) {
+ if (seek_error) {
+ av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");
+ exit_program(1);
+ }
av_log(NULL, AV_LOG_WARNING, "-to value smaller than -ss; ignoring -to.\n");
o->stop_time = INT64_MAX;
} else {
@@ -2799,6 +2804,8 @@ const OptionDef options[] = {
{ "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT |
OPT_INPUT, { .off = OFFSET(accurate_seek) },
"enable/disable accurate seeking with -ss" },
+ { "seek_error", OPT_BOOL | OPT_EXPERT, { &seek_error },
+ "exit on seek errors" },
{ "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET |
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_ts_offset) },
"set the input ts offset", "time_off" },
--
2.1.2
More information about the ffmpeg-devel
mailing list