Open ablwr opened 6 years ago
As basic as you can get, no real explanation needed:
sox input.mp3 output.wav
I often need to convert my files to mono:
sox input.mp3 -c 1 output.wav
Same again but alternate syntax:
sox input.mp3 output.wav channels 1
Use soxi
to display details of an audio file:
soxi audiofile.ext
Example:
$ soxi thing_on_a_spring.mp3
Input File : 'thing_on_a_spring.mp3'
Channels : 1
Sample Rate : 44100
Precision : 16-bit
Duration : 00:03:38.28 = 9626104 samples = 16370.9 CDDA sectors
File Size : 2.12M
Bit Rate : 77.6k
Sample Encoding: MPEG audio (layer I, II or III)
Comments :
Title=Thing on a Spring
Artist=Rob Hubbard
The same can be done with the main sox
program:
sox --i audiofile.ext
@JonnyTech you're a powerhouse!!!!!!
Extract audio channels:
left channel: sox infile.ext outfile.wav remix 1 0
right channel: sox infile.ext outfile.wav remix 0 1
Or if multi channels...
Mix channels 1 and 3 into a single channel file: sox infile.ext -c 1 outfile.ext remix 1 0 1
Almost forgot my useful command; generate a 10 second 1khz sinewave test tone:
sox -n 1k_tone.wav synth 10 sine 1000
All this can be done with ffmpeg.
Indeed, I never said that it could not, ie:
ffmpeg -f lavfi -i "sine=frequency=1000:sample_rate=44100:duration=10" -c:a pcm_s16le -ac 2 1k_tone.wav
But this is a sox
thread ;)
Which could also be expressed as:
ffmpeg -lavfi "sine=frequency=1000:sample_rate=44100:duration=10" -c:a pcm_s16le -ac 2 1k_tone_.wav
;-)
Yeah! Half the battle for people learning about these things is understanding whats possible and why things run the way they do. It doesn't matter if ffmpeg can also do it. Maybe it's fun to see something implemented in a different way using a different library!
@privatezero Could I possibly task you with writing a summary/introduction to sox and why people might find it useful?
Is there any difference between FFMpeg's astats and sox's stat and stats? I played around these a while back, and I believe one of the sox outputs is unique (though maybe I didn't really know all the astats could do).
As discussed in #310 and #309, we'd like to add an sox section to ffmprovisr, but we need recipes! Please share small scripts here! Especially you @privatezero!