Converting mp3 to ogg in php on joomla

6

I'm trying to convert an mp3 file to ogg using ffmpeg.exe The problem is that Joomla does not let me run an external file, even in the same directory.

<?php exec('C:\path\to\ffmpeg.exe -y -i file.mp3 -acodec libvorbis file.ogg'); ?>

This code does not return any errors, it just does not execute. Is there any other way to run ffmpeg.exe within Joomla? Or is there a way to convert direct via php that Joomla accepts?

    
asked by anonymous 29.04.2015 / 21:31

2 answers

1

I was able to run and convert the file, but only in the same directory where ffmpeg.exe is, then I had to move it. Before calling the exec call I activated safe_mode and added the directory where I am working and it worked.

ini_set('safe_mode',true);
ini_set('safe_mode_exec_dir','C:\path\to\');
exec('C:\path\to\ffmpeg.exe -y -i file.mp3 -acodec libvorbis file.ogg');

I do not know if this is the best way, but it worked. I moved the file using JFile :: move () .

    
04.05.2015 / 15:04
1

safe_mode is deprecated in PHP5.3 and has been removed in PHP5.4

The correct way is to use the exec function with $output and pass the arguments with escapeshellcmd (in the case of Windows), if it is linux / like-unix use the command escapeshellarg

Example:

<?php
$comando = 'C:\path\to\ffmpeg.exe';
$argumentos = escapeshellcmd('-y -i file.mp3 -acodec libvorbis file.ogg');

exec($comando . ' ' . $argumentos, $output);

echo '<pre>';
print_r($output);
echo '</pre>';
    
21.06.2015 / 16:11