Package timeside :: Package encoder :: Module ogg
[hide private]
[frames] | no frames]

Source Code for Module timeside.encoder.ogg

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (c) 2010 Paul Brossier <piem@piem.org> 
 4  # Copyright (c) 2010 Guillaume Pellerin <yomguy@parisson.com> 
 5   
 6  # This file is part of TimeSide. 
 7   
 8  # TimeSide is free software: you can redistribute it and/or modify 
 9  # it under the terms of the GNU General Public License as published by 
10  # the Free Software Foundation, either version 2 of the License, or 
11  # (at your option) any later version. 
12   
13  # TimeSide is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU General Public License for more details. 
17   
18  # You should have received a copy of the GNU General Public License 
19  # along with TimeSide.  If not, see <http://www.gnu.org/licenses/>. 
20   
21   
22  from timeside.core import Processor, implements, interfacedoc 
23  from timeside.encoder.core import GstEncoder 
24  from timeside.api import IEncoder 
25  from timeside.tools import * 
26 27 -class VorbisEncoder(GstEncoder):
28 """ gstreamer-based vorbis encoder """ 29 implements(IEncoder) 30 31 @interfacedoc
32 - def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
33 super(VorbisEncoder, self).setup(channels, samplerate, blocksize, totalframes) 34 self.pipe = ''' appsrc name=src 35 ! audioconvert 36 ! vorbisenc quality=0.9 37 ! oggmux 38 ''' 39 40 if self.filename and self.streaming: 41 self.pipe += ''' ! tee name=t 42 ! queue ! filesink location=%s 43 t. ! queue ! appsink name=app sync=False 44 ''' % self.filename 45 46 elif self.filename : 47 self.pipe += '! filesink location=%s async=False sync=False ' % self.filename 48 else: 49 self.pipe += '! queue ! appsink name=app sync=False ' 50 51 self.start_pipeline(channels, samplerate)
52 53 54 @staticmethod 55 @interfacedoc
56 - def id():
57 return "gst_vorbis_enc"
58 59 @staticmethod 60 @interfacedoc
61 - def description():
62 return "Vorbis GStreamer based encoder"
63 64 @staticmethod 65 @interfacedoc
66 - def format():
67 return "OGG"
68 69 @staticmethod 70 @interfacedoc
71 - def file_extension():
72 return "ogg"
73 74 @staticmethod 75 @interfacedoc
76 - def mime_type():
77 return "application/ogg"
78 79 @interfacedoc
80 - def set_metadata(self, metadata):
81 self.metadata = metadata
82