avconv: fix bitrate report when writing to /dev/null
authorJanne Grunau <janne-libav@jannau.net>
Tue, 9 Oct 2012 21:22:49 +0000 (23:22 +0200)
committerJanne Grunau <janne-libav@jannau.net>
Thu, 25 Oct 2012 13:00:15 +0000 (15:00 +0200)
avio_size() reports the filesize which returns 0 for /dev/null.
avio_tell() reports the current position.

Also handle errors from avio_tell().

avconv.c

index bf1e2fa..54a0e2a 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -807,8 +807,15 @@ static void print_report(int is_last_report, int64_t timer_start)
     oc = output_files[0]->ctx;
 
     total_size = avio_size(oc->pb);
-    if (total_size < 0) // FIXME improve avio_size() so it works with non seekable output too
+    if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too
         total_size = avio_tell(oc->pb);
+    if (total_size < 0) {
+        char errbuf[128];
+        av_strerror(total_size, errbuf, sizeof(errbuf));
+        av_log(NULL, AV_LOG_VERBOSE, "Bitrate not available, "
+               "avio_tell() failed: %s\n", errbuf);
+        total_size = 0;
+    }
 
     buf[0] = '\0';
     ti1 = 1e10;