From 1166a5eb35bd273189120b4b48d48f5d65a01d59 Mon Sep 17 00:00:00 2001 From: yomguy Date: Fri, 11 Mar 2011 10:16:09 +0000 Subject: [PATCH] add streaming test --- timeside/tests/api/test_lolevel_streaming.py | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 timeside/tests/api/test_lolevel_streaming.py diff --git a/timeside/tests/api/test_lolevel_streaming.py b/timeside/tests/api/test_lolevel_streaming.py new file mode 100644 index 0000000..cdf2754 --- /dev/null +++ b/timeside/tests/api/test_lolevel_streaming.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +from timeside.core import * +from timeside.decoder import * +from timeside.analyzer import * +from timeside.encoder import * +from timeside.api import * + +import sys +if len(sys.argv) > 1: + source = sys.argv[1] +else: + import os.path + source= os.path.join (os.path.dirname(__file__), "../samples/guitar.wav") + +decoder = FileDecoder(source) +print "Creating decoder with id=%s for: %s" % (decoder.id(), source) +decoder.setup() +channels = decoder.channels() +print channels +samplerate = decoder.samplerate() +nframes = decoder.nframes() + +dest1 = "/tmp/test.mp3" +dest2 = "/tmp/test2.mp3" +f = open(dest2,'w') + +encoder = WavEncoder(dest1, streaming=True) +encoder.setup(channels=channels, samplerate=samplerate) + +print encoder.pipe + +while True: + buf, eod = encoder.process(*decoder.process()) + f.write(buf) + if eod : + break + +f.close() + -- 2.39.5