improve decoding file switchover

This commit is contained in:
Jakob Ketterl 2021-05-02 00:06:50 +02:00
parent 0fa8774493
commit 290f67735d

View File

@ -56,7 +56,9 @@ class AudioWriter(object):
return WaveFile(filename) return WaveFile(filename)
def getNextDecodingTime(self): def getNextDecodingTime(self):
t = datetime.utcnow() # add one second to have the intervals tick over one second earlier
# this avoids filename collisions, but also avoids decoding wave files with less than one second of audio
t = datetime.utcnow() + timedelta(seconds=1)
zeroed = t.replace(minute=0, second=0, microsecond=0) zeroed = t.replace(minute=0, second=0, microsecond=0)
delta = t - zeroed delta = t - zeroed
seconds = (int(delta.total_seconds() / self.interval) + 1) * self.interval seconds = (int(delta.total_seconds() / self.interval) + 1) * self.interval