Thank you for this module. Exactly what I needed. One problem - no documentation and I had to patch the code to make it work correctly, it kept giving me SOX file errors. After some investigation I found out that the module is not adding the directory path to the output file.
I also wanted the file extension to be changed from .wav or .WAV to .mp3 (currently the module just adds the .mp3 part to the current filename).
I changed the following in audiosoxfield.module line 125-135 from
function _convert_helper(&$job) {
$videofile = escapeshellarg($job->filepath); // escape file name for safety
$convfile = basename($job->filename . ".mp3");
$converter = variable_get('sox_executable_path', '/usr/bin/sox');
To the following - please forgive my PHP - and could not get the correct pattern with preg_replace which is better than the str_replace I used.
The problem was with the $convfile variable - in the original code the path is lost.
function _convert_helper(&$job) {
$videofile = escapeshellarg($job->filepath); // escape file name for safety
$convfile = str_replace(array('.wav', '.WAV'), '.mp3', $videofile); // replace wav and WAV with mp3 in output file and retains path of original file
$convfile = str_replace("'", '', $convfile); // had to add this for some reason it gives a SOX error if the ' is not removed in the output filepath
$converter = variable_get('sox_executable_path', '/usr/bin/sox');
Hope this is of use.
Comments
Comment #1
MrVictor commentedGreat!
I'm a noob at PHP, might using substring increase performance? Mainely curiosity :-)
I suppose it's not considered a safe way.