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

Source Code for Module timeside.encoder.m4a

 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 implements, interfacedoc 
23  from timeside.encoder.core import GstEncoder 
24  from timeside.api import IEncoder 
25  from timeside.tools import * 
26 27 28 -class AacEncoder(GstEncoder):
29 """ gstreamer-based AAC encoder """ 30 implements(IEncoder) 31
32 - def __init__(self, output, streaming = False, overwrite = False):
33 super(AacEncoder, self).__init__(output, streaming, overwrite) 34 if self.streaming: 35 raise Exception("Streaming not supported")
36 37 @interfacedoc
38 - def setup(self, channels=None, samplerate=None, blocksize=None, totalframes=None):
39 super(AacEncoder, self).setup(channels, samplerate, blocksize, totalframes) 40 41 self.streaming = False 42 self.pipe = ''' appsrc name=src 43 ! audioconvert 44 ! voaacenc 45 ! mp4mux 46 ''' 47 48 if self.filename and self.streaming: 49 self.pipe += ''' ! tee name=t 50 ! queue ! filesink location=%s 51 t. ! queue ! appsink name=app sync=False 52 ''' % self.filename 53 54 elif self.filename : 55 self.pipe += '! filesink location=%s async=False sync=False ' % self.filename 56 else: 57 self.pipe += '! queue ! appsink name=app sync=False ' 58 59 self.start_pipeline(channels, samplerate)
60 61 62 @staticmethod 63 @interfacedoc
64 - def id():
65 return "gst_aac_enc"
66 67 @staticmethod 68 @interfacedoc
69 - def description():
70 return "AAC GStreamer based encoder"
71 72 @staticmethod 73 @interfacedoc
74 - def format():
75 return "AAC"
76 77 @staticmethod 78 @interfacedoc
79 - def file_extension():
80 return "m4a"
81 82 @staticmethod 83 @interfacedoc
84 - def mime_type():
85 return "audio/x-m4a"
86 87 @interfacedoc
88 - def set_metadata(self, metadata):
89 self.metadata = metadata
90