SoX resample and convert

43,797

SoX determines the files type by looking at its extension. To adjust the rate of the output file, add the -r option to the output files formatting options. From the manual synopsis:

sox 
  [global-options]
  [format-options] infile1 [[format-options] infile2] ...
  [format-options] outfile
  [effect [effect-options]] ...

Items in brackets are optional, ... means zero or more of the previous item.

Here is an example of how to perform both actions with one command:

sox master.wav -r 22050 out.ogg

Alternatively, you could add the rate manipulation to the effects chain:

sox master.wav out.ogg rate 22050
Share:
43,797
Admin
Author by

Admin

Updated on July 05, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to figure out how to combine two commands in SoX. My master file is 44.1 kHz. I first want to resample this file to 22 kHz and then convert it to mp3/opus/ogg. How can I do this with a single command?

  • awerchniak
    awerchniak almost 3 years
    Do you need additional libraries for this? I get: sox FAIL formats: no handler for file extension `ogg'
  • Thor
    Thor over 2 years
    @AndyW: you can see what audio formats your version of sox was compiled with by running: sox -h