diff mbox

[FFmpeg-devel] fftools/ffmpeg: check sseof value and clash with ss

Message ID 0fce1010-f31e-5d82-8304-dbb0fc326c64@gmail.com
State Superseded
Headers show

Commit Message

Gyan June 22, 2018, 4:39 p.m. UTC
From 326e15dcfc3ddb1d9b8fd06a5806807917f56669 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg@gyani.pro>
Date: Fri, 22 Jun 2018 22:02:16 +0530
Subject: [PATCH] fftools/ffmpeg: check sseof value and clash with ss

Prioritize -ss
---
 fftools/ffmpeg_opt.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index a2ecddae71..a5cedbcfff 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1103,9 +1103,18 @@  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\n", filename);
+        o->start_time_eof = AV_NOPTS_VALUE;
+    }
+
     if (o->start_time_eof != AV_NOPTS_VALUE) {
-        if (ic->duration>0) {
+        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; ignored\n");
+                o->start_time = AV_NOPTS_VALUE;
+            }
         } else
             av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename);
     }