Closed yomguy closed 1 year ago
hello,
when decoding the last frame of a compressed file, aubio.source
may return one empty block with no frames at all.
here is a patch to let the encoder ignore such empty blocks:
index 2c8a649b..e75daaba 100644
--- a/timeside/core/aubio_encoder.py
+++ b/timeside/core/aubio_encoder.py
@@ -78,6 +78,9 @@ class AubioEncoder(Processor):
indices = range(max_write, frames.shape[0], max_write)
for f_slice in np.array_split(frames, indices):
write_frames = f_slice.shape[0]
- self.sink.do_multi(f_slice.T.copy(), write_frames)
- self.num_samples += write_frames
+ if write_frames > 0:
+ self.sink.do_multi(f_slice.T.copy(), write_frames)
+ self.num_samples += write_frames
+ elif write_frames < 0:
+ raise ValueError ("can not encode a negative number of frames")
return frames, eod
thanks @piem could you commit this?
For example, retrieving the audio stream of this video with youtube-dl:
https://www.youtube.com/watch?v=04854XqcfCY
results to this:
https://timeside.ircam.fr/media/items/download/Queen_-_We_Are_The_Champions_Official_Video-04854XqcfCY.m4a
and encoding it to FLAC with timeside returns: