Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SoX resample and convert

Tags:

ffmpeg

audio

sox

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?

like image 954
sylowgreen Avatar asked Jun 01 '14 13:06

sylowgreen


1 Answers

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
like image 199
Thor Avatar answered Nov 08 '22 12:11

Thor