diff mbox

[FFmpeg-devel,1/3] tools/aviocat: add verbose mode.

Message ID 20190719122354.32460-1-george@nsup.org
State New
Headers show

Commit Message

Nicolas George July 19, 2019, 12:23 p.m. UTC
For now: print the input size as detected by AVSEEK_SIZE.

Signed-off-by: Nicolas George <george@nsup.org>
---
 tools/aviocat.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

Comments

Andreas Rheinhardt July 19, 2019, 12:30 p.m. UTC | #1
Nicolas George:
> For now: print the input size as detected by AVSEEK_SIZE.
> 
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  tools/aviocat.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/aviocat.c b/tools/aviocat.c
> index 2aa08b92ed..7dca4f52b5 100644
> --- a/tools/aviocat.c
> +++ b/tools/aviocat.c
> @@ -26,14 +26,14 @@
>  
>  static int usage(const char *argv0, int ret)
>  {
> -    fprintf(stderr, "%s [-b bytespersec] [-d duration] [-oi <options>] [-oo <options>] input_url output_url\n", argv0);
> +    fprintf(stderr, "%s [-b bytespersec] [-d duration] [-oi <options>] [-oo <options>] [-v] input_url output_url\n", argv0);
>      fprintf(stderr, "<options>: AVOptions expressed as key=value, :-separated\n");
>      return ret;
>  }
>  
>  int main(int argc, char **argv)
>  {
> -    int bps = 0, duration = 0, ret, i;
> +    int bps = 0, duration = 0, verbose = 0, ret, i;
>      const char *input_url = NULL, *output_url = NULL;
>      int64_t stream_pos = 0;
>      int64_t start_time;
> @@ -65,6 +65,8 @@ int main(int argc, char **argv)
>                  return usage(argv[0], 1);
>              }
>              i++;
> +        } else if (!strcmp(argv[i], "-v")) {
> +            verbose = 1;
>          } else if (!input_url) {
>              input_url = argv[i];
>          } else if (!output_url) {
> @@ -82,6 +84,15 @@ int main(int argc, char **argv)
>          fprintf(stderr, "Unable to open %s: %s\n", input_url, errbuf);
>          return 1;
>      }
> +    if (verbose) {
> +        int64_t size = avio_seek(input, 0, AVSEEK_SIZE);
This is only allowed after AVSEEK_SIZE is allowed to be usable from
outside, i.e. your first two patches should be swapped.
> +        if (size >= 0) {
> +            fprintf(stderr, "aviocat: input size: %"PRId64"\n", size);
> +        } else {
> +            fprintf(stderr, "aviocat: input size: unknown\n");
> +        }
> +    }
> +    exit(0);

Leftover from your testing?

>      if (duration && !bps) {
>          int64_t size = avio_size(input);
>          if (size < 0) {
>
Nicolas George July 19, 2019, 12:47 p.m. UTC | #2
Andreas Rheinhardt (12019-07-19):
> This is only allowed after AVSEEK_SIZE is allowed to be usable from
> outside, i.e. your first two patches should be swapped.

It will only print "unknown". And with dynamic linking plus the fact
that it was a public API, it is good to know what happens when
AVSEEK_SIZE is used before the first patch.

> > +    exit(0);
> Leftover from your testing?

Thank you for catching it. Locally fixed.

Regards,
diff mbox

Patch

diff --git a/tools/aviocat.c b/tools/aviocat.c
index 2aa08b92ed..7dca4f52b5 100644
--- a/tools/aviocat.c
+++ b/tools/aviocat.c
@@ -26,14 +26,14 @@ 
 
 static int usage(const char *argv0, int ret)
 {
-    fprintf(stderr, "%s [-b bytespersec] [-d duration] [-oi <options>] [-oo <options>] input_url output_url\n", argv0);
+    fprintf(stderr, "%s [-b bytespersec] [-d duration] [-oi <options>] [-oo <options>] [-v] input_url output_url\n", argv0);
     fprintf(stderr, "<options>: AVOptions expressed as key=value, :-separated\n");
     return ret;
 }
 
 int main(int argc, char **argv)
 {
-    int bps = 0, duration = 0, ret, i;
+    int bps = 0, duration = 0, verbose = 0, ret, i;
     const char *input_url = NULL, *output_url = NULL;
     int64_t stream_pos = 0;
     int64_t start_time;
@@ -65,6 +65,8 @@  int main(int argc, char **argv)
                 return usage(argv[0], 1);
             }
             i++;
+        } else if (!strcmp(argv[i], "-v")) {
+            verbose = 1;
         } else if (!input_url) {
             input_url = argv[i];
         } else if (!output_url) {
@@ -82,6 +84,15 @@  int main(int argc, char **argv)
         fprintf(stderr, "Unable to open %s: %s\n", input_url, errbuf);
         return 1;
     }
+    if (verbose) {
+        int64_t size = avio_seek(input, 0, AVSEEK_SIZE);
+        if (size >= 0) {
+            fprintf(stderr, "aviocat: input size: %"PRId64"\n", size);
+        } else {
+            fprintf(stderr, "aviocat: input size: unknown\n");
+        }
+    }
+    exit(0);
     if (duration && !bps) {
         int64_t size = avio_size(input);
         if (size < 0) {