After comparing how Asterisk plays wav vs wav16 I want to up the quality of my recordings. I see Asterisk supports sln12, sln16, sln24 etc. I was not able to find a tool to convert files to sln32. Is it a matter of figuring out the ffmpeg syntax then renaming the file?
There is no point in using high sample rates unless the whole end to end path supports high bandwidth audio. For most of the PSTN, the audio is limited to 3.1kHz (300 - 3,400 Hz), with a sample rate of 8kHz. Anything above plain .sln will be wasted on that. The exceptions don’t go above 7kHz audio, so .sln16 will be better than anything on the PSTN, or mobile networks.
I think you are playing a numbers game, without any real life benefits.
I assume sln192 is an uncorrected typo for sln32, as even for high quality music (not over a phone line), the highest sample rate used is only 48 kHz, aiming for a 20kHz audio bandwidth, which won’t benefit anyone after their mid teens.
(Mobile phone codecs, even if high audio bandwidth, trade off the ability to represent music against getting low bit rates for human speech. I don’t think any of those have effective audio bandwidths beyond 7kHz.)
Just a note that
ffmpeg allows you to specify container formats and codecs independently of filename extensions–the extensions just provide a default behaviour. So there shouldn’t be any need to rename the file, just generate it with the desired codec, format and name to begin with.
This also means you can feed
ffmpeg output to a pipe, or have it read input data from a pipe. Exercise: check the output from
ffmpeg -formats | grep -F pipe
The difference won’t be very audible unless you happen to use codecs in transit that actually support higher rates. Are you using a codec in transit that supports a higher rate?
I run µ-law on my PBX; this is an 8khz codec for Asterisk, so there’s no advantage to using a higher rate. If anything it just raises the resource usage of Asterisk having to resample and then convert from PCM.
sln12/16/24/etc. are literally just sample rate conversions. For example; a few of my MOH streams are sourced from 16khz OGG files and OGG123 spits out 16khz PCM. I have to specify the format as sln16. So an sln32 file is just a 32khz sample rate.
You should stick to the native codec as much as possible if you want to optimize what little sound quality you have.
I have found audio formats always confusing. The reason I asked this question is because I used to use ffmpeg to convert files to gsm and the quality on the phone wasn’t the best. I started controverting to wav and it was a bit better. When I used wav16 it was even better. I know that the PSTN is limited to 8khz, when testing though the higher the bit rate the better it sounded on the phone.
If it helps, note the distinction between codecs and container formats. The former is how the bits are encoded, while the latter is how those bits are stored in a file. So, for example,
.wav is a container format, while the audio in it might be stored in some uncompressed linear PCM format with, say, 16 bits per sample. Or the audio might be encoded as 8-bit µ-law.
When you capture audio with Asterisk, I think you end up with raw files, with no actual container format: instead the encoded samples are just written to the file as is. FFmpeg can cope with this, but you do have to tell it what the codec format is, since there is no container formatting to convey that information.
You get a limited choice, e.g. .sln is raw 16 bit signed linear mono 8kHZ, and .wav is the same in an RIFF wrapper. .gsm is raw GSM, and .WAV and .wav49 are RIFF wrapped GSM.