2

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:

    #fullHour is a boolean
    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]

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).

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?

Any thoughts would be greatly appreciated, thanks!

DRT
  • 21
  • 3

1 Answers1

1

It’s really simple. The command you say works, sox old.ogg -C 192.2 new.mp3, would look like this in array notation:

[ 'sox', 'old.ogg', '-C', '192.2', 'new.mp3']

Note how every space starts a new argument, because it is not quoted or escaped.

user219095
  • 65,551