Home | Trees | Indices | Help |
|
---|
|
1 # -*- coding: utf-8 -*- 2 # 3 # Copyright (C) 2007-2012 Parisson SARL 4 # Copyright (c) 2006-2012 Guillaume Pellerin <pellerin@parisson.com> 5 # Copyright (c) 2010-2012 Paul Brossier <piem@piem.org> 6 # Copyright (c) 2009-2010 Olivier Guilyardi <olivier@samalyse.com> 7 8 9 # This file is part of TimeSide. 10 11 # TimeSide is free software: you can redistribute it and/or modify 12 # it under the terms of the GNU General Public License as published by 13 # the Free Software Foundation, either version 2 of the License, or 14 # (at your option) any later version. 15 16 # TimeSide is distributed in the hope that it will be useful, 17 # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 # GNU General Public License for more details. 20 21 # You should have received a copy of the GNU General Public License 22 # along with TimeSide. If not, see <http://www.gnu.org/licenses/>. 23 24 # Authors: Guillaume Pellerin <yomguy@parisson.com> 25 # Paul Brossier <piem@piem.org> 26 27 from timeside.core import implements, interfacedoc 28 from timeside.encoder.core import GstEncoder 29 from timeside.api import IEncoder 30 from timeside.tools import * 31 32 import mutagen35 """ gstreamer-based mp3 encoder """ 36 implements(IEncoder) 37 38 @interfacedoc10640 super(Mp3Encoder, self).setup(channels, samplerate, blocksize, totalframes) 41 42 self.pipe = '''appsrc name=src 43 ! audioconvert 44 ! lamemp3enc target=quality quality=2 encoding-engine-quality=standard 45 ! xingmux 46 ! id3v2mux 47 ''' 48 49 if self.filename and self.streaming: 50 self.pipe += ''' ! tee name=t 51 ! queue ! filesink location=%s 52 t. ! queue ! appsink name=app sync=False 53 ''' % self.filename 54 55 elif self.filename : 56 self.pipe += '! filesink location=%s async=False sync=False ' % self.filename 57 else: 58 self.pipe += '! queue ! appsink name=app sync=False ' 59 60 self.start_pipeline(channels, samplerate)61 62 @staticmethod 63 @interfacedoc 66 67 @staticmethod 68 @interfacedoc 71 72 @staticmethod 73 @interfacedoc 76 77 @staticmethod 78 @interfacedoc 81 82 @staticmethod 83 @interfacedoc 86 87 @interfacedoc 9092 """Write all ID3v2.4 tags to file from self.metadata""" 93 from mutagen import id3 94 id3 = id3.ID3(self.filename) 95 for tag in self.metadata.keys(): 96 value = self.metadata[tag] 97 frame = mutagen.id3.Frames[tag](3,value) 98 try: 99 id3.add(frame) 100 except: 101 raise IOError('EncoderError: cannot tag "'+tag+'"') 102 try: 103 id3.save() 104 except: 105 raise IOError('EncoderError: cannot write tags')
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Dec 15 00:09:37 2013 | http://epydoc.sourceforge.net |