From edc46ee824eff5846272f31510be593cc758a28f Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Thu, 20 Jun 2019 17:24:56 -0500 Subject: [PATCH] Added _format and bitrate parameters to the transcoder so it will be more flexible. The default for mp3 now is 320 KBPS --- src/controller/player.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controller/player.py b/src/controller/player.py index 28b8f48..edfc486 100644 --- a/src/controller/player.py +++ b/src/controller/player.py @@ -110,7 +110,7 @@ class audioPlayer(object): #https://github.com/ZeBobo5/Vlc.DotNet/issues/4 call_threaded(self.next) - def transcode_audio(self, item, path): + def transcode_audio(self, item, path, _format="mp3", bitrate=320): """ Converts given item to mp3. This method will be available when needed automatically.""" if item.download_url == "": item.get_download_url() @@ -118,7 +118,7 @@ class audioPlayer(object): temporary_filename = "chunk_{0}".format(random.randint(0,2000000)) temporary_path = os.path.join(os.path.dirname(path), temporary_filename) # Let's get a new VLC instance for transcoding this file. - transcoding_instance = vlc.Instance(*["--sout=#transcode{acodec=mp3,ab=192}:file{mux=raw,dst=\"%s\"}"% (temporary_path,)]) + transcoding_instance = vlc.Instance(*["--sout=#transcode{acodec=%s,ab=%d}:file{mux=raw,dst=\"%s\"}"% (_format, bitrate, temporary_path,)]) transcoder = transcoding_instance.media_player_new() transcoder.set_mrl(item.download_url) pub.sendMessage("change_status", status=_(u"Downloading {0}.").format(item.title,))