Technological journey's of a lonely African Programmer
In: Ruby on Rails
14 Jan 2010Was working on a module in one of my Rails projects and I had to find the length of the audio file clients uploaded to that they can be billed accordingly, since this was voice sms it was very crucial. I combed the whole internet for solutions and could not find any, came across a few gems that were great but lacked what I really needed, so I decided to sit my butt down and role out the code myself.
The first idea was using FFMPEG on the command line to extract the length, did some few searches and came across the exact line I needed. You need to install ffmpeg first before this will work. I code on Mac OS X, my personal production server at home is RedHat Enterprise 5 and the main production server is running Ubuntu Linux. so I have the luxury of learning all three install methods.
For mac you need macport installed then you run
sudo port install ffmpeg
On RHEL5 i had a lot of dependency problems but resolved them by adding the ATRPMS Repo (Really a saved me), how to add the repo to you Linux distribution is available on thier website. I wont cover it here, once you done, you can install ffmpeg with
sudo yum install ffmpeg
On Ubuntu Linux ( Debian Systems), you install ffmpeg using
sudo apt-get install ffmpeg
All said and done lets try a commandline demo and see it it really works.
ffmpeg -i “/Users/nukturnal/Desktop/try.mp3″ 2>&1 | grep ‘Duration’ | cut -d ‘ ‘ -f 4 | sed s/,//
Just tackling programming nightmares with flares. Sometimes the tactics are smooth sometimes their rough.