From: Paul Brossier Date: Tue, 29 Jan 2013 03:20:23 +0000 (-0500) Subject: tests/api/test_enc_mp3_by_block.py: add transcode example by block X-Git-Tag: 0.4.3~1^2~1 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=6064a5330d690ccd990d3d5bb4e4ce1818e6acc7;p=timeside.git tests/api/test_enc_mp3_by_block.py: add transcode example by block --- diff --git a/tests/api/test_enc_mp3_by_block.py b/tests/api/test_enc_mp3_by_block.py new file mode 100644 index 0000000..eb90b72 --- /dev/null +++ b/tests/api/test_enc_mp3_by_block.py @@ -0,0 +1,33 @@ +from numpy import vstack, zeros + +from timeside.decoder import * +from timeside.encoder import * + +import sys, os.path + +def transcode(source, target): + decoder = FileDecoder(source) + decoder.setup() + + channels = decoder.channels() + samplerate = decoder.samplerate() + + print channels, samplerate + + encoder = Mp3Encoder(target) + encoder.setup(channels = channels, samplerate = samplerate) + + totalframes = 0 + while True: + frames, eod = decoder.process() + encoder.process(frames, eod) + totalframes += frames.shape[0] + if eod or encoder.eod: + break + +if __name__ == '__main__': + + if len(sys.argv) < 3: + print 'needs 2 args' + sys.exit(1) + transcode(sys.argv[1], sys.argv[2])