gremlin/gremlin.in: Try querying duration early to guess bitrate.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 20 Apr 2018 12:21:24 +0000 (13:21 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 20 Apr 2018 12:21:24 +0000 (13:21 +0100)
This seems to work reliably now.

gremlin/gremlin.in

index fe9491d..c0383ed 100644 (file)
@@ -913,7 +913,10 @@ class AudioIdentifier (object):
     elif 'bitrate' in tags and tags['bitrate'] >= 80000:
       me._bitrate = tags['bitrate']/1000
     else:
-      me._bitrate = None
+      ok, n = pipe.query_duration(GS.Format.BYTES)
+      if ok: ok, t = pipe.query_duration(GS.Format.TIME)
+      if ok: me._bitrate = int((8e6*n)/t)
+      else: me._bitrate = None
     pipe.set_state(GS.State.NULL)
 
   @property