Changeset 27a5b88 for telemeta/export/flac.py
- Timestamp:
- 05/21/07 01:20:38 (6 years ago)
- Branches:
- master, crem, crem2, dev, diadems, forma, generic, instru_search, lam, nlivemulti, production, release/1.4.4, security, social, storage, test, video
- Children:
- dfc0718
- Parents:
- 3e80d17
- git-author:
- yomguy <> (05/21/07 01:20:38)
- git-committer:
- yomguy <> (05/21/07 01:20:38)
- File:
-
- 1 edited
-
telemeta/export/flac.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
telemeta/export/flac.py
re9a21a3 r27a5b88 86 86 media.save() 87 87 88 def process(self, item_id, source, metadata, options=None): 89 self.item_id = item_id 90 self.source = source 91 self.metadata = metadata 92 self.options = {} 88 def get_args(self,options=None): 89 """Get process options and return arguments for the encoder""" 93 90 args = '' 94 95 91 if not options is None: 96 92 self.options = options 97 98 if 'verbose' in self.options and self.options['verbose'] != '0': 99 args = args 100 else: 93 if not ('verbose' in self.options and self.options['verbose'] != '0'): 101 94 args = args + ' -s ' 102 95 103 96 if 'flac_quality' in self.options: 104 97 args = args+' -f -'+self.options['flac_quality'] … … 107 100 else: 108 101 args = args+' -s -f -'+self.quality_default 109 102 return args 103 104 def process(self, item_id, source, metadata, options=None): 105 self.item_id = item_id 106 self.source = source 107 self.metadata = metadata 108 #self.options = {} 109 self.args = self.get_args(options) 110 self.ext = self.get_file_extension() 111 self.command = 'sox "'+self.source+'" -q -w -r 44100 -t wav -c2 - '+ \ 112 '| flac '+self.args+' -c -' 113 114 # Pre-proccessing 110 115 try: 111 # Pre-proccessing (core)112 self.ext = self.get_file_extension()113 116 self.dest = self.pre_process(self.item_id, 114 117 self.source, … … 117 120 self.cache_dir, 118 121 self.options) 119 120 # Initializing 121 chunk = 0 122 file_out = open(self.dest,'w') 123 124 proc = subprocess.Popen( \ 125 'sox "'+self.source+'" -q -w -r 44100 -t wav -c2 - '+ 126 '| flac '+args+' -c -', 127 shell=True, 128 bufsize=self.buffer_size, 129 stdin=subprocess.PIPE, 130 stdout=subprocess.PIPE, 131 close_fds=True) 122 except: 123 yield 'ExporterError [3]: pre_process' 132 124 133 chunk = proc.stdout.read(self.buffer_size) 134 yield chunk 135 file_out.write(chunk) 125 # Processing (streaming + cache writing) 126 try: 127 stream = self.core_process(self.command,self.buffer_size,self.dest) 128 for chunk in stream: 129 yield chunk 130 except: 131 yield 'ExporterError: core_process' 136 132 137 # Processing 138 while chunk: 139 chunk = proc.stdout.read(self.buffer_size) 140 yield chunk 141 file_out.write(chunk) 142 143 #file_in.close() 144 file_out.close() 145 146 # Encoding 147 #os.system('flac '+args+' -o "'+self.dest+'" "'+ \ 148 # self.source+'" > /dev/null') 149 150 # Post-proccessing (self) 151 self.write_tags() 133 # Post-proccessing 134 try: 135 self.write_tags() 152 136 self.post_process(self.item_id, 153 137 self.source, … … 156 140 self.cache_dir, 157 141 self.options) 142 except: 143 yield 'ExporterError: post_process' 158 144 159 # Output160 #return self.dest161 145 162 except IOError:163 yield 'ExporterError [3]: source file does not exist.'164 146 # Encoding 147 #os.system('flac '+args+' -o "'+self.dest+'" "'+ \ 148 # self.source+'" > /dev/null')
Note: See TracChangeset
for help on using the changeset viewer.
