diff mbox

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

Message ID 8918e57c-d14d-fac8-e76e-aa638501f1fd@gmail.com
State Superseded
Headers show

Commit Message

Gyan June 23, 2018, 4:47 a.m. UTC
Added another check and corrected an oversight in a log message.
From f013a502c438ef9940fc131cad9bf870853adb5f Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg@gyani.pro>
Date: Fri, 22 Jun 2018 22:02:16 +0530
Subject: [PATCH v2] fftools/ffmpeg: check sseof value and clash with ss

Prioritize -ss
---
 fftools/ffmpeg_opt.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Comments

Gyan June 24, 2018, 6:58 p.m. UTC | #1
Will push in a day if no comments.

(fixed the missing loglevel locally)

Gyan
Michael Niedermayer June 25, 2018, 1:09 a.m. UTC | #2
On Sat, Jun 23, 2018 at 10:17:45AM +0530, Gyan Doshi wrote:
> 
> Added another check and corrected an oversight in a log message.

>  ffmpeg_opt.c |   16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 663aeb89592e5538ac36e738815b105ab0708d6f  v2-0001-fftools-ffmpeg-check-sseof-value-and-clash-with-s.patch
> From f013a502c438ef9940fc131cad9bf870853adb5f Mon Sep 17 00:00:00 2001
> From: Gyan Doshi <ffmpeg@gyani.pro>
> Date: Fri, 22 Jun 2018 22:02:16 +0530
> Subject: [PATCH v2] fftools/ffmpeg: check sseof value and clash with ss
> 
> Prioritize -ss
> ---
>  fftools/ffmpeg_opt.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index a2ecddae71..c728c344a7 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -1103,12 +1103,26 @@ 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, "-sseof value must be negative; aborting\n");

arguments types are wrong


> +            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);


>      }
> +
>      timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time;

unrelated, this should not be in this patch

thx


[...]
diff mbox

Patch

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index a2ecddae71..c728c344a7 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1103,12 +1103,26 @@  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, "-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);
     }
+
     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)