]> git.sesse.net Git - ffmpeg/commitdiff
fftools/ffmpeg: check sseof value and clash with ss
authorGyan Doshi <ffmpeg@gyani.pro>
Fri, 22 Jun 2018 16:32:16 +0000 (22:02 +0530)
committerGyan Doshi <ffmpeg@gyani.pro>
Tue, 26 Jun 2018 04:17:32 +0000 (09:47 +0530)
Prioritize -ss

fftools/ffmpeg_opt.c

index a2ecddae7191a59a253ad53da89d3952db5a3560..58ec13e5a8fce9e447e0c4cab61576828494ce0b 100644 (file)
@@ -1103,9 +1103,22 @@ static int open_input_file(OptionsContext *o, const char *filename)
         }
     }
 
+    if (o->start_time != AV_NOPTS_VALUE && o->start_time_eof != AV_NOPTS_VALUE) {
+        av_log(NULL, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss for %s\n", filename);
+        o->start_time_eof = AV_NOPTS_VALUE;
+    }
+
     if (o->start_time_eof != AV_NOPTS_VALUE) {
-        if (ic->duration>0) {
+        if (o->start_time_eof >= 0) {
+            av_log(NULL, AV_LOG_ERROR, "-sseof value must be negative; aborting\n");
+            exit_program(1);
+        }
+        if (ic->duration > 0) {
             o->start_time = o->start_time_eof + ic->duration;
+            if (o->start_time < 0) {
+                av_log(NULL, AV_LOG_WARNING, "-sseof value seeks to before start of file %s; ignored\n", filename);
+                o->start_time = AV_NOPTS_VALUE;
+            }
         } else
             av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename);
     }