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

Source Code for Module timeside.encoder.flac

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