I have spent a large chunk of the past two weekends trying to find some kind of instructions as to how to get audio into the native Asterisk “SLN” format. Specifically, I wanted to convert some mp3s of classical music (such as from Musopen) to SLN for music-on-hold. I was able to discern that SLN files are “raw” or headerless “wav” format, 16-bit signed PCM or signed linear (hence SLN). After several attempts to convert mp3s, wavs, and other things to this format, only to have them play as painfully loud static, I tried reversing the process and importing some working sample SLN files in Audacity. This led to the big ah-ha! moment of the weekend—the Asterisk SLN files are 16-bit little-endian signed PCM, whereas SoX, Audacity, et al, were putting out big-endian 16-bit signed PCM. I couldn’t for the life of me find an option to change the endiannes in Audacity, however.
In searching some more, I found that ffmpeg, one of the best swiss-army-knife-type audio/video conversion programs, specifically supports signed 16-bit little-endian PCM. Here’s the command to convert just about any audio (anything ffmpeg can handle) to the appropriate format for Asterisk music-on-hold:
ffmpeg -i "[input file]" -ar 8000 -ac 1 -acodec pcm_s16le -f s16le "[output file].sln"
You may also want to add a volume modifier, to make the music appropriately quiet for music-on-hold, and ffmpeg allows this to be specified in dB gain like “-vol -15dB”.
Comments 1
sox has options for endianness:
-L, –endian little
-B, –endian big
Thus, “-t raw -c 1 -r 8000 -L -s -2 filename.sln” should work, both for input and output.
Posted 19 Nov 2008 at 1:37 pm ¶Trackbacks & Pingbacks 1
[...] | user-saved public links | iLinkShare 1 votesConverting to Asterisk-Native SLN Audio with ffmpeg>> saved by nolemonoftroy 1 days ago2 votesPlaying Video from your Linux PC on your Wii>> saved by [...]