2718.us blog » mp3 http://2718.us/blog Miscellaneous Technological Geekery Tue, 18 May 2010 02:42:55 +0000 en hourly 1 http://wordpress.org/?v=3.0.4 Converting to Asterisk-Native SLN Audio with ffmpeg http://2718.us/blog/2008/07/21/converting-to-asterisk-native-sln-audio-with-ffmpeg/ http://2718.us/blog/2008/07/21/converting-to-asterisk-native-sln-audio-with-ffmpeg/#comments Mon, 21 Jul 2008 13:31:00 +0000 2718.us http://2718.us/blog/?p=62 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”.

]]>
http://2718.us/blog/2008/07/21/converting-to-asterisk-native-sln-audio-with-ffmpeg/feed/ 2