Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sox recipes #312

Open
ablwr opened this issue Mar 28, 2018 · 13 comments
Open

sox recipes #312

ablwr opened this issue Mar 28, 2018 · 13 comments

Comments

@ablwr
Copy link
Member

ablwr commented Mar 28, 2018

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!

@JonnyTech
Copy link

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

sox input.mp3 output.wav

@JonnyTech
Copy link

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
Copy link

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
Copy link

The same can be done with the main sox program:

sox --i audiofile.ext

@ablwr
Copy link
Member Author

ablwr commented Mar 28, 2018

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

@JonnyTech
Copy link

JonnyTech commented Mar 28, 2018

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
Copy link

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

sox -n 1k_tone.wav synth 10 sine 1000

@richardpl
Copy link

All this can be done with ffmpeg.

@JonnyTech
Copy link

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

@retokromer
Copy link
Member

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

;-)

@ablwr
Copy link
Member Author

ablwr commented Mar 29, 2018

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
Copy link
Member Author

ablwr commented Mar 29, 2018

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

@bturkus
Copy link
Contributor

bturkus commented Mar 29, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants