]> git.parisson.com Git - timeside.git/commitdiff
VorbisEncoder : passing the low level app and file streaming test
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 13 Feb 2014 23:04:54 +0000 (00:04 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 13 Feb 2014 23:06:43 +0000 (00:06 +0100)
tests/sandbox/test_lolevel_streaming_threaded.py
tests/sandbox/test_lolevel_streaming_threaded_ogg.py [new file with mode: 0644]
timeside/encoder/mp3.py

index c0bcffa81281cfc1d9f552005b3ad4555857c34e..ef2ca608f2d8dc16b7f5f6a08bb08be2668782d1 100644 (file)
@@ -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 (file)
index 0000000..881ddbe
--- /dev/null
@@ -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
index 8c781ecec253a5cb5f1e3471a3217d2392471b4b..d1b1053d619f82c23528b3d5f2e035ca9045d95b 100644 (file)
@@ -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)