From c5ca93054363d1a3e3c3f5b578c3539c98eb89dc Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Fri, 14 Feb 2014 00:04:54 +0100 Subject: [PATCH] VorbisEncoder : passing the low level app and file streaming test --- .../test_lolevel_streaming_threaded.py | 1 - .../test_lolevel_streaming_threaded_ogg.py | 54 +++++++++++++++++++ timeside/encoder/mp3.py | 2 +- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 tests/sandbox/test_lolevel_streaming_threaded_ogg.py diff --git a/tests/sandbox/test_lolevel_streaming_threaded.py b/tests/sandbox/test_lolevel_streaming_threaded.py index c0bcffa..ef2ca60 100644 --- a/tests/sandbox/test_lolevel_streaming_threaded.py +++ b/tests/sandbox/test_lolevel_streaming_threaded.py @@ -55,4 +55,3 @@ assert os.path.getsize(dest1) == os.path.getsize(dest2) # INFO : sweep.mp3 transcoded with pure gst from sweep.flac with the same parameters # as in the timeside mp3 encoder gives 70535 bytes - diff --git a/tests/sandbox/test_lolevel_streaming_threaded_ogg.py b/tests/sandbox/test_lolevel_streaming_threaded_ogg.py new file mode 100644 index 0000000..881ddbe --- /dev/null +++ b/tests/sandbox/test_lolevel_streaming_threaded_ogg.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- + +from timeside.core import * +from timeside.decoder import FileDecoder +from timeside.encoder import Mp3Encoder, VorbisEncoder + +import sys +if len(sys.argv) > 1: + source = sys.argv[1] +else: + import os.path + audio_file = '../samples/sweep.flac' + source = os.path.join(os.path.dirname(__file__), audio_file) + +decoder = FileDecoder(audio_file) + +print "Creating decoder with id=%s for: %s" % (decoder.id(), audio_file) + +dest1 = "/tmp/test_filesink.ogg" +dest2 = "/tmp/test_appsink.ogg" +f = open(dest2, 'w') + + +streaming = True +encoder = VorbisEncoder(dest1, streaming=streaming, overwrite=True) + +pipe = (decoder | encoder) +print pipe +#pipe.run() + +for chunk in pipe.stream(): + f.write(chunk) +#while True: +# encoder.process(*decoder.process()) +# if streaming: +# f.write(encoder.chunk) +# if encoder.eod: +# break + +f.close() +#print encoder.pipe + +import os +dest1_size = os.path.getsize(dest1) +dest2_size = os.path.getsize(dest2) + +print "sizes : %d , %d" % (dest1_size, dest2_size) + +assert os.path.getsize(dest1) == os.path.getsize(dest2) + +# Sometime randomly freeze +# Appsink file is always 1 buffer longer than filesink +# TODO : Try to transcode with a pure gstreamer pipe to see the file length +# maybe appsink is fine but filesink not ? just to be checked diff --git a/timeside/encoder/mp3.py b/timeside/encoder/mp3.py index 8c781ec..d1b1053 100644 --- a/timeside/encoder/mp3.py +++ b/timeside/encoder/mp3.py @@ -55,7 +55,7 @@ class Mp3Encoder(GstEncoder): elif self.filename : self.pipe += '! filesink location=%s async=False sync=False ' % self.filename else: - self.pipe += '! queue ! appsink name=app sync=False async=True' + self.pipe += '! queue ! appsink name=app sync=False' self.start_pipeline(channels, samplerate) -- 2.39.5