amiaopensource / ffmprovisr

Repository of useful FFmpeg commands for archivists!
https://amiaopensource.github.io/ffmprovisr/
528 stars 66 forks source link

sox recipes #312

Open ablwr opened 6 years ago

ablwr commented 6 years ago

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 commented 6 years ago

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

sox input.mp3 output.wav

JonnyTech commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

The same can be done with the main sox program:

sox --i audiofile.ext

ablwr commented 6 years ago

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

JonnyTech commented 6 years ago

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 commented 6 years ago

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

sox -n 1k_tone.wav synth 10 sine 1000

richardpl commented 6 years ago

All this can be done with ffmpeg.

JonnyTech commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

bturkus commented 6 years ago

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