예제 #1
0
 def computeVariableBitrate(self, mp3):
     if self.quality <= QUALITY_FAST:
         return
     count = 0
     if QUALITY_BEST <= self.quality:
         self.warning(
             "Process all MPEG audio frames to compute exact duration")
         max_count = None
     else:
         max_count = 500 * self.quality
     total_bit_rate = 0.0
     for index, frame in enumerate(mp3.array("frames/frame")):
         if index < 3:
             continue
         bit_rate = frame.getBitRate()
         if bit_rate:
             total_bit_rate += float(bit_rate)
             count += 1
             if max_count and max_count <= count:
                 break
     if not count:
         return
     bit_rate = total_bit_rate / count
     self.bit_rate = (bit_rate,
                      _("%s (Variable bit rate)") % humanBitRate(bit_rate))
     duration = timedelta(seconds=float(mp3["frames"].size) / bit_rate)
     self.duration = duration
예제 #2
0
 def computeVariableBitrate(self, mp3):
     if self.quality <= QUALITY_FAST:
         return
     count = 0
     if QUALITY_BEST <= self.quality:
         self.warning("Process all MPEG audio frames to compute exact duration")
         max_count = None
     else:
         max_count = 500 * self.quality
     total_bit_rate = 0.0
     for index, frame in enumerate(mp3.array("frames/frame")):
         if index < 3:
             continue
         bit_rate = frame.getBitRate()
         if bit_rate:
             total_bit_rate += float(bit_rate)
             count += 1
             if max_count and max_count <= count:
                 break
     if not count:
         return
     bit_rate = total_bit_rate / count
     self.bit_rate = (bit_rate,
         _("%s (Variable bit rate)") % humanBitRate(bit_rate))
     duration = timedelta(seconds=float(mp3["frames"].size) / bit_rate)
     self.duration = duration
예제 #3
0
 def computeBitrate(self, frame):
     bit_rate = frame.getBitRate()  # may returns None on error
     if not bit_rate:
         return
     self.bit_rate = (bit_rate, _("%s (constant)") % humanBitRate(bit_rate))
     self.duration = timedelta(seconds=float(frame["/frames"].size) /
                               bit_rate)
예제 #4
0
 def computeBitrate(self, frame):
     bit_rate = frame.getBitRate() # may returns None on error
     if not bit_rate:
         return
     self.bit_rate = (bit_rate, _("%s (constant)") % humanBitRate(bit_rate))
     self.duration = timedelta(seconds=float(frame["/frames"].size) / bit_rate)