Audio with the first 30 seconds mute

0

I'm using this code more unsuccessfully but in the terminal it works perfectly what it can be?

exec("ffmpeg -i musica.mp3 -af "volume=enable='between(t,0,30)':volume=0" result.mp3 2> log.txt"); 

The music is in the php folder, I even use other commands in the files successfully. The server is linux, the command runs perfectly through the putty terminal. but needed to run through php.

    
asked by anonymous 18.12.2015 / 21:02

1 answer

1

It has a strange error, I do not know how it did not syntax error, but here you used quotation marks inside the quotation marks of the first argument of exec :

... -af "volume=enable='between(t,0,30)':volume=0" ...
        ^ - Aqui                                 ^ aqui

You should escape them like this:

exec("ffmpeg -i musica.mp3 -af \"volume=enable='between(t,0,30)':volume=0\" result.mp3 2> log.txt"); 

I also recommend that you use escapeshellarg with exec (if it's Like-unix) and use the absolute path as a precaution.

It should look like this:

//Pega o caminho todo do script atual
define('FULL_PATH', rtrim(strtr(dirname(__FILE__), '\', '/'), '/') . '/');

$sourcePath = FULL_PATH . 'musica.mp3';
$savePath   = FULL_PATH . 'result.mp3';
$params     = escapeshellarg('"volume=enable=\'between(t,0,30)\':volume=0"');

exec('ffmpeg -i ' . $sourcePath . ' -af ' . $params . ' ' . $savePath . ' 2> log.txt');
    
18.12.2015 / 21:15