self.test_duration = True
self.test_channels = True
self.filesize_delta = None
+ self.expected_sample_rate = None
def testMp3(self):
"Test conversion to mp3"
"Test conversion to ogg"
self.encoder_function = VorbisEncoder
+ def testOpus(self):
+ "Test conversion to opus"
+ self.encoder_function = OpusEncoder
+ self.expected_sample_rate = 48000
+
def testWebM(self):
"Test conversion to webm"
self.encoder_function = WebMEncoder
else:
self.assertEqual(2, decoder_encoded.channels()) # voaacenc bug ?
- self.assertEqual(decoder.samplerate(),
+ if not self.expected_sample_rate:
+ self.expected_sample_rate = decoder.samplerate()
+ self.assertEqual(self.expected_sample_rate,
decoder_encoded.samplerate())
if self.test_duration:
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007-2014 Parisson SARL
+# Copyright (c) 2006-2014 Guillaume Pellerin <pellerin@parisson.com>
+# Copyright (c) 2010-2014 Paul Brossier <piem@piem.org>
+# Copyright (c) 2009-2010 Olivier Guilyardi <olivier@samalyse.com>
+# Copyright (c) 2013-2014 Thomas Fillon <thomas@parisson.com>
+
+# This file is part of TimeSide.
+
+# TimeSide is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# TimeSide is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with TimeSide. If not, see <http://www.gnu.org/licenses/>.
+
+# Authors: Guillaume Pellerin <yomguy@parisson.com>
+# Paul Brossier <piem@piem.org>
+# Thomas Fillon <thomas@parisson.com>
+
+from timeside.core import implements, interfacedoc
+from timeside.encoder.core import GstEncoder
+from timeside.api import IEncoder
+
+
+class OpusEncoder(GstEncoder):
+ """ gstreamer-based mp3 encoder """
+ implements(IEncoder)
+
+ @interfacedoc
+ def setup(self, channels=None, samplerate=None, blocksize=None,
+ totalframes=None):
+ super(OpusEncoder, self).setup(channels, samplerate, blocksize,
+ totalframes)
+
+ self.pipe = '''appsrc name=src
+ ! audioconvert ! audioresample
+ ! opusenc audio=true
+ ! oggmux
+ '''
+
+ if self.filename and self.streaming:
+ self.pipe += ''' ! tee name=t
+ ! queue ! filesink location=%s
+ t. ! queue! appsink name=app sync=False
+ ''' % self.filename
+
+ elif self.filename:
+ self.pipe += '! filesink location=%s async=False sync=False ' % self.filename
+ else:
+ self.pipe += '! queue ! appsink name=app sync=False'
+
+ self.start_pipeline(channels, samplerate)
+
+ @staticmethod
+ @interfacedoc
+ def id():
+ return "gst_opus_enc"
+
+ @staticmethod
+ @interfacedoc
+ def description():
+ return "Opus GStreamer based encoder"
+
+ @staticmethod
+ @interfacedoc
+ def format():
+ return "Opus"
+
+ @staticmethod
+ @interfacedoc
+ def file_extension():
+ return "opus"
+
+ @staticmethod
+ @interfacedoc
+ def mime_type():
+ return "audio/mpeg"
+
+ @interfacedoc
+ def set_metadata(self, metadata):
+ self.metadata = metadata