Python Forum
Using SoX in Python to Increase mp3 Bitrate
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using SoX in Python to Increase mp3 Bitrate
#1
I am trying to increase the bitrate on an mp3 in an audio archiving program written in Python, that uses SoX.

Here's a portion of the code:

    DeltaSeconds = chunk['TimeDelta'].total_seconds()
    fullHour = (3540 < DeltaSeconds < 3660 )        
    targetMp3 = ''.join((tmpFolder, '/', str(x), '.mp3'))
    if fullHour: # no trim necesary, just convert to mp3
        # print tab,'fullHour [',str(x),']'
        # print tab,'    ','SourceOgg -> ', str(SourceOgg)
        # print tab,'    ', 'targetMp3 -> ', str(targetMp3)
        cmd = ['sox', SourceOgg, targetMp3]
        print cmd
        call(cmd)
This is what I tried:

cmd = ['sox', SourceOgg, '-C 192.2', targetMp3]
I ran this in the command line on my Ubuntu machine, and it worked perfectly:

sox old.ogg -C 192.2 new.mp3

So I believe it's something specific to running the command in python. I may be missing something with the syntax?

According to the documentation, this should work. Here is the full project: AutoCharlie

The source file is an ogg (Sample Rate 44100,Bits per sample 32, Bitrate 499 kpbs).

Any thoughts would be greatly appreciated, thanks!
Reply
#2
Update... to make it work in an array, just had to do this:

cmd = ['sox', SourceOgg, '-C', '192.2', targetMp3]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Increase the speed of a python loop over a pandas dataframe mcva 0 1,323 Jan-21-2022, 06:24 PM
Last Post: mcva
  How to increase the size of a png picture for the heatmap of the correlation? lulu43366 9 3,538 Oct-06-2021, 04:15 PM
Last Post: deanhystad
  Clicker count increase by 1 each time blakefindlay 1 5,699 Feb-03-2021, 03:50 PM
Last Post: deanhystad
  increase and decrease a slice value? KEYS 2 2,105 Nov-10-2020, 11:35 PM
Last Post: KEYS
  Increase Numbers forever and need reset? ATARI_LIVE 4 2,355 Oct-23-2020, 01:55 PM
Last Post: ATARI_LIVE
  How do I add an element to a dic and increase an existing value Kanashi 2 1,865 Nov-21-2019, 02:56 PM
Last Post: ThomasL
  How to increase the data size SriRajesh 3 4,057 Nov-10-2018, 04:29 PM
Last Post: ichabod801
  Want to increase performance of adb call fabiofacir 0 2,904 Jun-30-2018, 11:39 AM
Last Post: fabiofacir
  Matplotlib Colorbar Ticks (Increase number) BennyS 1 8,846 Apr-18-2018, 04:00 PM
Last Post: BennyS
  How does multi-processing in python increase the execution time? kadsank 0 2,333 Jan-15-2018, 01:15 PM
Last Post: kadsank

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020