ffmprovisr icon indicating copy to clipboard operation
ffmprovisr copied to clipboard

sox recipes

Open ablwr opened this issue 7 years ago • 13 comments

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!

ablwr avatar Mar 28 '18 19:03 ablwr

As basic as you can get, no real explanation needed:

sox input.mp3 output.wav

JonnyTech avatar Mar 28 '18 23:03 JonnyTech

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

JonnyTech avatar Mar 28 '18 23:03 JonnyTech

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

JonnyTech avatar Mar 28 '18 23:03 JonnyTech

The same can be done with the main sox program:

sox --i audiofile.ext

JonnyTech avatar Mar 28 '18 23:03 JonnyTech

@JonnyTech you're a powerhouse!!!!!!

ablwr avatar Mar 28 '18 23:03 ablwr

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

JonnyTech avatar Mar 28 '18 23:03 JonnyTech

Almost forgot my useful command; generate a 10 second 1khz sinewave test tone:

sox -n 1k_tone.wav synth 10 sine 1000

JonnyTech avatar Mar 28 '18 23:03 JonnyTech

All this can be done with ffmpeg.

richardpl avatar Mar 29 '18 07:03 richardpl

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

JonnyTech avatar Mar 29 '18 08:03 JonnyTech

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

;-)

retokromer avatar Mar 29 '18 10:03 retokromer

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!

ablwr avatar Mar 29 '18 14:03 ablwr

@privatezero Could I possibly task you with writing a summary/introduction to sox and why people might find it useful?

ablwr avatar Mar 29 '18 14:03 ablwr

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

bturkus avatar Mar 29 '18 14:03 bturkus