10

I have installed sox with support for both mp3 and flac.

The below command also successfully converts flac to mp3

sox /song_files/Daughter_of_Evil.flac /song_files/Daughter_of_Evil.mp3

My problem is that the "Daughter_of_Evil.mp3" is not 320 bit mp3. I tried to specify sampling rate of 44100. But that did not change the bit rate. It stays at 128kbps.

How can I directly generate 320 bit mp3 file for above flac file.

I can convert 128 bit mp3 to 320 bit mp3 using LAME. But the quality is already lost in 128 bit mp3 file generated above. Hence I want it done in single step.

Thanks

user1058797
  • 799
  • 3
  • 9
  • 18

2 Answers2

14

You are looking for the -C option to SoX:

sox input.flac -C 320 output.mp3
chirlu
  • 2,796
  • 1
  • 19
  • 22
  • I get this warning: sox WARN mp3: -C option not supported for mp3; using default compression rate How can I enable this. Thanks – user1058797 Aug 16 '13 at 12:18
  • @user1058797: What version is this? It should work since SoX 14.3.1. – chirlu Aug 16 '13 at 12:33
  • it is version 14.3.0 I will install 14.3.1 and try it again. Thanks :) – user1058797 Aug 16 '13 at 12:59
  • 1
    i configured sox 14.4.1, it didnt have flac. So i installed flac 1.2.1. Now for sox, when I try to run command 'make', i get the error: /var/software/sox_dir/sox-14.4.0/src/flac.c:310: undefined reference to `FLAC__stream_encoder_set_compression_level' and some other FLAC related errors, and it stops with error 1. Any fixes for this? Thanks. – user1058797 Aug 17 '13 at 09:31
  • @user1058797: This is in the linking step, isn't it? It seems static linking is attempted and fails, but it's not clear what is happening. – chirlu Aug 17 '13 at 14:33
  • Not sure what is linking. I am using centos. 'configure' command completes succesfully with support for flac and wav. The 'make' command and 'install' command generates this error. Thanks. – user1058797 Aug 19 '13 at 04:54
  • @user1058797: It seems the FLAC install is not complete. How did you install it? I read that on CentOS, it should be enough to install the `flac-devel` package via the package manager. – chirlu Aug 19 '13 at 09:49
  • flac-devel installs an older version and it is not detected by sox 14.4.1, so i downloaded it from this link: downloads.sourceforge.net/project/flac/flac-src/flac-1.2.1-src/flac-1.2.1.tar.gz, compiled it and installed it. Then got the error during compilation of sox. Thanks. – user1058797 Aug 19 '13 at 14:10
  • Thank you @chirlu ! It took me so long to get this answer for some reason.... really appreciated. – AdamJones Dec 11 '15 at 20:42
0

Just to add, 128kbps is the standard sox mp3 conversion. Also, if you're encoding from a lower bit rate, it will stay at the lower bit rate unless you explicitly specify a higher rate.

For instance, say File 1 is 320 kbps, sox will convert to 128 kbps

sox file1.mp3 file2.mp3

In this instance, say File 1 is 64kbps, sox will process the conversion, but at the same bit rate:

sox file1.mp3 file2.mp3

In which case, if you need to increase the bit rate, you need to explicitly set the bit rate, as follows:

sox file1.mp3 -C 320 file2.mp3
Glenn Cooper
  • 127
  • 1
  • 13