Skip to content

Commit

Permalink
number of channels OK
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrice Zaoui committed Jun 3, 2019
1 parent 7b655fa commit 370b437
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions ReleaseNote.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
VERSION 0.4
-----------
- User-defined sample rate frequency for DSF lossless conversion
- Choose the number of channels (Default-Multi, Mono, Stereo)
- APE input format added
- Bug fix dsf to ogg format

Expand Down
20 changes: 11 additions & 9 deletions mp3Thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
class MP3Thread(QThread):
update_progress_bar = pyqtSignal()

def __init__(self, audio_files, lossless_folder, lossy_location, qvalue, codec, samplerate):
def __init__(self, audio_files, lossless_folder, lossy_location, qvalue, codec, samplerate, channels):
QThread.__init__(self)
self.audio_files = audio_files
self.lossless_folder = lossless_folder
self.lossy_location = lossy_location
self.qval = qvalue
self.codec = codec
self.samplerate = samplerate
self.channels = channels
self.sep = '/'
self.null = '/dev/null'
if os.name == 'nt':
Expand All @@ -68,6 +69,7 @@ def convert2lossy(self, audio_file_in):
except OSError:
# logging.exception('Unable to create the destination folder')
pass
chn = '-ac ' + str(self.channels) + ' '
if self.codec == 'MP3':
ext = 'mp3'
audio_file = file_name + '.' + ext
Expand All @@ -76,7 +78,7 @@ def convert2lossy(self, audio_file_in):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn -acodec libmp3lame -q:a '+ self.qval + ' -map_metadata 0'
+ ' -id3v2_version 3 '
+ ' -id3v2_version 3 ' + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
elif self.codec == 'AAC':
Expand All @@ -86,7 +88,7 @@ def convert2lossy(self, audio_file_in):
if not os.path.isfile(audio_file_out):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn -acodec aac -b:a ' + self.qval + ' -map_metadata 0 '
+ ' -vn -acodec aac -b:a ' + self.qval + ' -map_metadata 0 ' + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
elif self.codec == 'Ogg Vorbis':
Expand All @@ -100,7 +102,7 @@ def convert2lossy(self, audio_file_in):
if not os.path.isfile(audio_file_out):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn -acodec libvorbis -q:a ' + self.qval + ' -map_metadata 0 ' + fe
+ ' -vn -acodec libvorbis -q:a ' + self.qval + ' -map_metadata 0 ' + fe + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
elif self.codec == 'Opus':
Expand All @@ -110,7 +112,7 @@ def convert2lossy(self, audio_file_in):
if not os.path.isfile(audio_file_out):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn -acodec libopus -b:a ' + self.qval + ' -map_metadata 0 '
+ ' -vn -acodec libopus -b:a ' + self.qval + ' -map_metadata 0 ' + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
elif self.codec == 'FLAC':
Expand All @@ -130,7 +132,7 @@ def convert2lossy(self, audio_file_in):
if not os.path.isfile(audio_file_out):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn -compression_level ' + self.qval + ' -map_metadata 0 ' + fe
+ ' -vn -compression_level ' + self.qval + ' -map_metadata 0 ' + fe + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
elif self.codec == 'ALAC':
Expand All @@ -150,7 +152,7 @@ def convert2lossy(self, audio_file_in):
if not os.path.isfile(audio_file_out):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn -acodec alac -compression_level ' + self.qval + ' -map_metadata 0 ' + fe
+ ' -vn -acodec alac -compression_level ' + self.qval + ' -map_metadata 0 ' + fe + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
elif self.codec == 'WAV':
Expand All @@ -170,7 +172,7 @@ def convert2lossy(self, audio_file_in):
if not os.path.isfile(audio_file_out):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn ' + ' -map_metadata 0 ' + fe
+ ' -vn ' + ' -map_metadata 0 ' + fe + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
elif self.codec == 'AIFF':
Expand All @@ -190,7 +192,7 @@ def convert2lossy(self, audio_file_in):
if not os.path.isfile(audio_file_out):
subprocess.call(ffmpeg + ' -nostats -loglevel 0 -i '
+ '"' + audio_file_in + '"'
+ ' -vn ' + ' -map_metadata 0 ' + fe
+ ' -vn ' + ' -map_metadata 0 ' + fe + chn
+ '"' + audio_file_out + '"' + ' > ' + self.null,
shell=True)
def run(self):
Expand Down
2 changes: 1 addition & 1 deletion pLACaudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def call_convert2lossy(self):
for i in range(len(audio)):
q = self.qval[self.myformat][self.myquality][0]
self.threads.append(MP3Thread(audio[i], self.lossless_folder, self.lossy_location, q, self.myformat,
self.samplerate))
self.samplerate, self.channels))
self.nstart = 0
for i in range(len(audio)):
self.threads[i].update_progress_bar.connect(self.update_progress_bar)
Expand Down

0 comments on commit 370b437

Please sign in to comment.